/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg:             #0d1117;
  --surface:        #161b22;
  --surface-2:      #1c2128;
  --surface-3:      #21262d;
  --border:         #30363d;
  --border-subtle:  #1e2430;
  --text:           #e6edf3;
  --text-muted:     #8b949e;
  --text-subtle:    #484f58;
  --accent:         #58a6ff;
  --accent-hover:   #79b8ff;
  --red:            #f85149;
  --red-bg:         rgba(248, 81, 73, 0.12);
  --orange:         #e3b341;
  --orange-bg:      rgba(227, 179, 65, 0.12);
  --green:          #3fb950;
  --green-bg:       rgba(63, 185, 80, 0.12);
  --yellow:         #d29922;
  --yellow-bg:      rgba(210, 153, 34, 0.12);
  --blue:           #58a6ff;
  --blue-bg:        rgba(88, 166, 255, 0.12);
  --grey-bg:        rgba(139, 148, 158, 0.12);

  --sidebar-w:      260px;
  --font:           'Outfit', system-ui, sans-serif;
  --mono:           'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --radius:         8px;
}

/* ============================================================
   RESET / BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-3);
  padding: 0.1em 0.4em;
  border-radius: 3px;
}

/* ============================================================
   SKIP LINK
   ============================================================ */
.app-skip-link {
  position: fixed;
  top: -80px;
  left: 12px;
  z-index: 9999;
  padding: 8px 16px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  transition: top 0.1s;
}
.app-skip-link:focus { top: 12px; outline: none; }

/* ============================================================
   SHELL
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.app-sidebar__header {
  padding: 24px 18px 20px;
  border-bottom: 1px solid var(--border);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}
.app-brand:hover { color: var(--text); text-decoration: none; }

.app-brand__icon { color: var(--accent); flex-shrink: 0; }

.app-brand__sub {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-subtle);
  letter-spacing: 0.04em;
}

/* ============================================================
   NAV
   ============================================================ */
.app-nav { padding: 14px 10px; flex: 1; }

.app-nav__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.app-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.app-nav__link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.app-nav__link.is-active { background: var(--surface-3); color: var(--text); }

.app-nav__link--urgent { color: var(--red); }
.app-nav__link--urgent:hover { color: var(--red); }
.app-nav__link--urgent.is-active { color: var(--red); }

.app-nav__icon { flex-shrink: 0; opacity: 0.55; }
.app-nav__link.is-active .app-nav__icon,
.app-nav__link:hover .app-nav__icon { opacity: 1; }

.app-nav__label { flex: 1; }

/* ============================================================
   BADGES (sidebar counts)
   ============================================================ */
.app-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  line-height: 1;
}
.app-badge--red    { background: var(--red-bg);    color: var(--red); }
.app-badge--orange { background: var(--orange-bg); color: var(--orange); }
.app-badge--blue   { background: var(--blue-bg);   color: var(--blue); }
.app-badge--grey   { background: var(--grey-bg);   color: var(--text-muted); }
.app-badge--yellow { background: var(--yellow-bg); color: var(--yellow); }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.app-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   ALERT BANNER (cooldown)
   ============================================================ */
.app-sidebar__actions {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.app-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.app-action-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border);
}
.app-action-btn__icon { opacity: 0.55; flex-shrink: 0; }
.app-action-btn:hover .app-action-btn__icon { opacity: 1; }

.app-alert {
  padding: 11px 32px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.app-alert--info {
  background: var(--blue-bg);
  color: var(--text-muted);
}
.app-alert--success {
  background: var(--green-bg);
  color: var(--green);
}
.app-alert--warning {
  background: var(--orange-bg);
  color: var(--orange);
}
.app-alert--error {
  background: var(--red-bg);
  color: var(--red);
}

/* ============================================================
   MAIN + PAGE HEADER
   ============================================================ */
.app-main { padding: 44px 56px 72px; }

.app-page-header { margin-bottom: 36px; }

.app-page-header__caption {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.app-page-header__title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}

.app-page-header__desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.app-page-header__meta {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-subtle);
}

.app-refresh-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
  padding: 0;
}
.app-refresh-btn:hover { color: var(--accent-hover); text-decoration: underline; }

/* ============================================================
   WARNING
   ============================================================ */
.app-warning {
  display: flex;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--orange-bg);
  border: 1px solid rgba(227,179,65,0.25);
  margin-bottom: 28px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}
.app-warning__icon { color: var(--orange); flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   FILTER FORM
   ============================================================ */
.app-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  padding: 20px 22px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.app-filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-filter-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.app-select {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 8px 32px 8px 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  min-width: 140px;
}
.app-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}
.app-select option { background: var(--surface-3); }

.app-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.app-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.4;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.app-btn--primary {
  background: var(--accent);
  color: #0d1117;
  border-color: var(--accent);
}
.app-btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #0d1117;
  text-decoration: none;
}
.app-btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.app-btn--ghost:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }

/* ============================================================
   TABLE
   ============================================================ */
.app-table-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.app-table-meta strong { color: var(--text); font-weight: 600; }

.app-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

table.app-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.app-table th {
  background: var(--surface);
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 13px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.app-table th a {
  color: var(--text-subtle);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.app-table th a:hover { color: var(--text-muted); }
.app-table th a.is-sorted { color: var(--accent); }
.app-sort-icon { opacity: 0.4; font-size: 10px; }
.is-sorted .app-sort-icon { opacity: 1; }

.app-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.app-table tr:last-child td { border-bottom: none; }
.app-table tbody tr:hover td { background: var(--surface); }

/* PR title cell */
.app-pr-title a {
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
}
.app-pr-title a:hover { color: var(--accent); }
.app-pr-number {
  display: inline-block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-subtle);
}

/* Mono text (repo, timestamps) */
.app-mono {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Status pills */
.app-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.7;
}
.app-pill--green  { background: var(--green-bg);  color: var(--green); }
.app-pill--red    { background: var(--red-bg);    color: var(--red); }
.app-pill--blue   { background: var(--blue-bg);   color: var(--blue); }
.app-pill--grey   { background: var(--grey-bg);   color: var(--text-muted); }
.app-pill--orange { background: var(--orange-bg); color: var(--orange); }
.app-pill--yellow { background: var(--yellow-bg); color: var(--yellow); }

.app-review-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.app-review-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-subtle);
}
.app-no-reviews { color: var(--text-subtle); font-size: 13px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.app-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.app-empty p { margin-bottom: 8px; }

/* ============================================================
   ERROR PAGE
   ============================================================ */
.app-error { max-width: 480px; }
.app-error__code {
  font-family: var(--mono);
  font-size: 56px;
  font-weight: 500;
  color: var(--text-subtle);
  line-height: 1;
  margin-bottom: 16px;
}
.app-error__title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.app-error__body {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 8px;
}

/* ============================================================
   GROUPED VIEW
   ============================================================ */
.app-group { margin-bottom: 40px; }

.app-group__heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.app-group__ticket {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: var(--blue-bg);
  padding: 3px 10px;
  border-radius: 20px;
}
.app-group__ticket:hover { color: var(--accent-hover); text-decoration: none; }
.app-group__ticket--none {
  color: var(--text-subtle);
  background: var(--grey-bg);
}

.app-group__count {
  font-size: 12px;
  color: var(--text-subtle);
  font-family: var(--mono);
}
