/* ============================================================
   ForgeTrack — Global Styles v2
   Vanilla CSS, no framework dependencies
============================================================ */

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

:root {
  --brand:        #0052cc;
  --brand-hover:  #0747a6;
  --brand-light:  #deebff;
  --green:        #00875a;
  --red:          #ff5630;
  --orange:       #ff991f;

  --gray-50:  #fafbfc;
  --gray-100: #f4f5f7;
  --gray-200: #ebecf0;
  --gray-300: #dfe1e6;
  --gray-400: #c1c7d0;
  --gray-500: #97a0af;
  --gray-600: #7a869a;
  --gray-700: #5e6c84;
  --gray-800: #42526e;
  --gray-900: #253858;
  --gray-950: #091e42;

  --text:     #172b4d;
  --text-2:   #5e6c84;
  --text-3:   #97a0af;
  --border:   #dfe1e6;
  --border-2: #ebecf0;
  --bg:       #f4f5f7;
  --surface:  #ffffff;

  --topbar-h: 56px;
  --topbar-bg: #091e42;
  --sidebar-w: 240px;

  --r-sm: 3px;
  --r-md: 4px;
  --r-lg: 8px;

  --shadow-sm: 0 1px 2px rgba(9,30,66,.13);
  --shadow-md: 0 3px 8px rgba(9,30,66,.16);
  --shadow-lg: 0 8px 24px rgba(9,30,66,.20);
  --shadow-xl: 0 20px 64px rgba(9,30,66,.24);

  --font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'IBM Plex Mono', 'Fira Code', monospace;

  --t-fast: 120ms ease;
  --t-base: 200ms ease;

  /* priority */
  --p-critical: #ff5630;
  --p-high:     #ff7452;
  --p-medium:   #ffab00;
  --p-low:      #2684ff;
  --p-trivial:  #97a0af;

  /* types */
  --t-bug:   #e01e5a;
  --t-task:  #0052cc;
  --t-story: #00875a;
  --t-epic:  #904ee2;
}

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

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

h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 600; }

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Layout shell ───────────────────────────────────────────────── */
.app-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.app-body  { display: flex; flex: 1; overflow: hidden; }
.page-content { flex: 1; overflow-y: auto; }

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); background: var(--topbar-bg);
  display: flex; align-items: center; padding: 0 16px;
  gap: 16px; flex-shrink: 0; position: relative; z-index: 100;
}
.topbar-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; flex-shrink: 0; }
.topbar-logo-text { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -.02em; }
.topbar-logo:hover { text-decoration: none; }
.topbar-nav { display: flex; gap: 4px; }
.topbar-nav-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 0 12px; height: 32px; background: transparent;
  border: none; border-radius: var(--r-md);
  color: rgba(255,255,255,.8); font-size: 14px; font-family: var(--font);
  cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.topbar-nav-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-right  { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.topbar-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: transparent; border: none;
  border-radius: var(--r-md); color: rgba(255,255,255,.7); cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.topbar-icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar-avatar-btn { background: transparent; border: none; padding: 0; cursor: pointer; border-radius: 50%; display: flex; }

/* Search */
.topbar-search { position: relative; width: 100%; max-width: 400px; }
.topbar-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,.4); pointer-events: none; }
.topbar-search-input {
  width: 100%; height: 32px; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.15); border-radius: var(--r-md);
  color: #fff; font-family: var(--font); font-size: 13px;
  padding: 0 12px 0 32px;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.topbar-search-input::placeholder { color: rgba(255,255,255,.4); }
.topbar-search-input:focus { outline: none; background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.3); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-xl); z-index: 200; overflow: hidden;
  display: none;
}
.search-results.show { display: block; }
.search-result-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px; background: none; border: none;
  text-align: left; font-family: var(--font); font-size: 13px;
  color: var(--text); cursor: pointer; transition: background var(--t-fast);
}
.search-result-item:hover { background: var(--gray-100); }
.search-result-key { min-width: 60px; font-family: var(--mono); font-size: 11px; color: var(--text-2); }
.search-result-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-project { font-size: 11px; color: var(--text-3); flex-shrink: 0; }

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border-2); overflow-y: auto; overflow-x: hidden;
}
.sidebar-project-header {
  display: flex; align-items: center; gap: 8px;
  padding: 16px; border-bottom: 1px solid var(--border-2);
}
.sidebar-project-icon {
  width: 30px; height: 30px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.sidebar-project-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-project-key  { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.sidebar-nav { padding: 8px 0; }
.sidebar-section-label {
  padding: 12px 16px 4px; font-size: 11px; font-weight: 700;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .06em;
}
.sidebar-link {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px; font-size: 13px; color: var(--text-2);
  text-decoration: none; border-left: 3px solid transparent;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-link:hover { background: var(--gray-100); color: var(--text); text-decoration: none; }
.sidebar-link.active { background: var(--brand-light); color: var(--brand); border-left-color: var(--brand); font-weight: 500; }
.sidebar-link svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ── Env badge ──────────────────────────────────────────────────── */
.env-chip {
  padding: 2px 7px; border-radius: 10px; font-size: 10px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.env-chip.development { background: #6554c0; color: #fff; }
.env-chip.staging     { background: var(--orange); color: #172b4d; }
.env-corner {
  position: fixed; bottom: 16px; right: 16px; z-index: 999;
  pointer-events: none;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; height: 32px; border-radius: var(--r-md);
  border: none; font-family: var(--font); font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.btn:focus-visible { outline: 2px solid #4c9aff; outline-offset: 2px; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); color: #fff; text-decoration: none; }
.btn-secondary { background: var(--gray-100); color: var(--text); }
.btn-secondary:hover { background: var(--gray-200); text-decoration: none; }
.btn-ghost     { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--gray-100); color: var(--text); text-decoration: none; }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { background: #de350b; text-decoration: none; }
.btn-sm  { height: 28px; font-size: 12px; padding: 0 8px; }
.btn-lg  { height: 40px; font-size: 15px; padding: 0 20px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-group  { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.form-label  { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.form-label.req::after { content: ' *'; color: var(--red); }
.form-hint   { font-size: 11px; color: var(--text-3); }
.form-error  { font-size: 12px; color: var(--red); }
.form-control {
  width: 100%; padding: 7px 12px; border: 2px solid var(--border);
  border-radius: var(--r-md); font-family: var(--font); font-size: 14px;
  color: var(--text); background: var(--surface);
  transition: border-color var(--t-fast); appearance: none;
}
.form-control:focus { outline: none; border-color: #4c9aff; }
.form-control::placeholder { color: var(--text-3); }
.form-control.err { border-color: var(--red); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235e6c84' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 32px; cursor: pointer;
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Card ───────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }

/* ── Badges ─────────────────────────────────────────────────────── */
.status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 2px;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.s-todo       { background: var(--gray-300); color: var(--gray-800); }
.s-inprogress { background: var(--brand);    color: #fff; }
.s-review     { background: var(--orange);   color: #172b4d; }
.s-done       { background: var(--green);    color: #fff; }
.s-cancelled  { background: var(--gray-500); color: #fff; }

.type-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 2px;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.ti-bug   { background: var(--t-bug);   color: #fff; }
.ti-task  { background: var(--t-task);  color: #fff; }
.ti-story { background: var(--t-story); color: #fff; }
.ti-epic  { background: var(--t-epic);  color: #fff; }

.label-chip { padding: 1px 6px; background: var(--gray-100); border-radius: 2px; font-size: 11px; color: var(--text-2); }

/* ── Avatar ─────────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 700; flex-shrink: 0;
  letter-spacing: -.02em; font-family: var(--font); color: #fff;
}

/* ── Priority ───────────────────────────────────────────────────── */
.pri { display: inline-flex; align-items: center; }
.pri-critical { color: var(--p-critical); }
.pri-high     { color: var(--p-high); }
.pri-medium   { color: var(--p-medium); }
.pri-low      { color: var(--p-low); }
.pri-trivial  { color: var(--p-trivial); }

/* ── Issue list row ─────────────────────────────────────────────── */
.issue-row {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; height: 40px; border-bottom: 1px solid var(--border-2);
  cursor: pointer; background: var(--surface); transition: background var(--t-fast);
  text-decoration: none; color: inherit;
}
.issue-row:hover { background: var(--gray-50); text-decoration: none; }
.issue-row:last-child { border-bottom: none; }
.ir-key   { font-family: var(--mono); font-size: 11px; color: var(--text-2); min-width: 68px; flex-shrink: 0; }
.ir-title { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ir-labels { display: flex; gap: 4px; flex-shrink: 0; }
.ir-meta  { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.ir-meta-item { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text-3); }

/* ── Issue group ─────────────────────────────────────────────────── */
.issue-group { overflow: hidden; margin-bottom: 8px; }
.issue-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; cursor: pointer; background: var(--gray-50);
  border-bottom: 1px solid var(--border-2);
  transition: background var(--t-fast); user-select: none;
}
.issue-group-header:hover { background: var(--gray-100); }
.group-count { font-size: 12px; color: var(--text-3); margin-left: 4px; }
.collapse-icon { transition: transform var(--t-base); color: var(--text-3); flex-shrink: 0; }
.collapse-icon.collapsed { transform: rotate(-90deg); }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(9,30,66,.54);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px; animation: fadeIn 150ms ease;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl); width: 100%; max-height: 90vh;
  overflow-y: auto; animation: slideUp 200ms ease;
}
.modal-sm { max-width: 400px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 860px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border-2);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-body   { padding: 24px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 12px; padding: 16px 24px; border-top: 1px solid var(--border-2);
}

/* ── Dropdown ───────────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  z-index: 200; overflow: hidden; animation: fadeIn 120ms ease; display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-menu-r { left: auto; right: 0; }
.dropdown-header { padding: 12px 16px; border-bottom: 1px solid var(--border-2); }
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 16px; background: none; border: none;
  text-align: left; font-family: var(--font); font-size: 14px;
  color: var(--text); cursor: pointer; transition: background var(--t-fast);
}
.dropdown-item:hover { background: var(--gray-100); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item svg { width: 14px; height: 14px; }
.dropdown-divider { height: 1px; background: var(--border-2); border: none; margin: 4px 0; }

/* ── Misc ───────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border-2); border: none; margin: 16px 0; }
.text-2  { color: var(--text-2); }
.text-3  { color: var(--text-3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.mono    { font-family: var(--mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fw-600  { font-weight: 600; }
.mt-4 { margin-top: 4px; }

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px 24px;
  text-align: center; color: var(--text-2); gap: 12px;
}
.empty-state svg { opacity: .3; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gray-950); color: #fff; padding: 10px 20px;
  border-radius: 20px; font-size: 13px; z-index: 2000;
  animation: fadeIn 200ms ease; box-shadow: var(--shadow-lg);
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

.spinner { animation: spin 700ms linear infinite; display: inline-block; }
.role-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 8px; background: var(--brand-light); color: var(--brand); }

/* ── Filter bar ─────────────────────────────────────────────────── */
.filter-bar { padding: 12px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.filter-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-right: 2px; }
.filter-chip {
  padding: 3px 10px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); font-size: 12px; color: var(--text-2);
  cursor: pointer; font-family: var(--font); transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.filter-chip:hover { background: var(--gray-100); }
.filter-chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.filter-count { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: var(--brand); color: #fff; border-radius: 9px; font-size: 10px; font-weight: 700; }

/* ── Stats ──────────────────────────────────────────────────────── */
.stats-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 32px; }
.stat-card { flex: 1; min-width: 100px; padding: 20px; }
.stat-value { font-size: 32px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-2); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.stat-blue .stat-value  { color: var(--brand); }
.stat-orange .stat-value { color: var(--orange); }
.stat-red .stat-value   { color: var(--red); }
.stat-green .stat-value { color: var(--green); }

/* ── Bar chart ──────────────────────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-label { width: 90px; font-size: 12px; color: var(--text-2); text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; height: 20px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; transition: width 600ms cubic-bezier(.4,0,.2,1); min-width: 4px; }
.bar-count { width: 30px; font-size: 12px; font-weight: 600; color: var(--text-2); text-align: right; flex-shrink: 0; }

/* ── Colour picker ──────────────────────────────────────────────── */
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; transition: transform var(--t-fast), border-color var(--t-fast);
  padding: 0; outline: none;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.sel   { border-color: var(--text); }

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin    { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Inline edit ─────────────────────────────────────────────────── */
.inline-edit {
  position: relative; cursor: pointer; border-radius: var(--r-md);
  padding: 4px; margin: -4px;
  transition: background var(--t-fast);
}
.inline-edit:hover { background: var(--gray-100); }
.inline-edit-pencil { opacity: 0; position: absolute; top: 6px; right: 6px; color: var(--text-3); }
.inline-edit:hover .inline-edit-pencil { opacity: 1; }
.inline-edit-input  { width: 100%; }

/* ── Password field ─────────────────────────────────────────────── */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 40px; }
.pw-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-3); cursor: pointer; padding: 4px; display: flex; align-items: center; }
.pw-toggle:hover { color: var(--text-2); }

/* ── Danger zone ─────────────────────────────────────────────────── */
.danger-zone { border-color: #ffd5cc !important; }
.danger-confirm {
  padding: 12px;
  background: var(--danger-bg, #fff5f5);
  border: 1px solid var(--danger-border, #ffd5cc);
  border-radius: var(--r-md);
  display: flex; flex-direction: column; gap: 8px;
  color: var(--text);
}

/* ── Page padding ────────────────────────────────────────────────── */
.page-pad { padding: 24px 32px; max-width: 1400px; margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; }

/* ── Section ─────────────────────────────────────────────────────── */
.section-card { padding: 24px; margin-bottom: 24px; }
.section-title { font-size: 14px; font-weight: 700; padding-bottom: 12px; border-bottom: 1px solid var(--border-2); margin-bottom: 20px; }

/* ================================================================
   RESPONSIVE / MOBILE STYLES
   Breakpoints:
     --mobile:  max 600px
     --tablet:  max 900px
================================================================ */

/* ── Mobile topbar adjustments ──────────────────────────────────── */
.topbar-menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px; background: transparent; border: none;
  border-radius: var(--r-md); color: rgba(255,255,255,.8); cursor: pointer;
  flex-shrink: 0; transition: background var(--t-fast);
}
.topbar-menu-btn:hover { background: rgba(255,255,255,.1); }

/* ── Mobile sidebar overlay ─────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(9,30,66,.5);
  z-index: 90; animation: fadeIn 150ms ease;
}
.sidebar-overlay.show { display: block; }

/* ── Bottom nav bar (mobile only) ───────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 56px; background: var(--surface);
  border-top: 1px solid var(--border-2);
  z-index: 80; padding: 0 8px;
  align-items: center; justify-content: space-around;
}
.bottom-nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 6px 12px; background: none; border: none;
  color: var(--text-3); font-size: 10px; font-family: var(--font);
  cursor: pointer; border-radius: var(--r-md); flex: 1;
  transition: color var(--t-fast);
  text-decoration: none;
}
.bottom-nav-btn.active { color: var(--brand); }
.bottom-nav-btn svg { width: 20px; height: 20px; }

/* ── Tablet (≤900px) ─────────────────────────────────────────────── */
@media (max-width: 900px) {

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
    z-index: 91; transform: translateX(-100%);
    transition: transform 250ms cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }

  /* Show hamburger button */
  .topbar-menu-btn { display: flex; }

  /* Hide the "Projects" nav button — redundant on mobile */
  .topbar-nav { display: none; }

  /* Shrink search */
  .topbar-search { max-width: 260px; }

  /* Reports grid: 1 col */
  .reports-grid { grid-template-columns: 1fr !important; }

  /* Dashboard grid: 1 col */
  .dashboard-grid { grid-template-columns: 1fr !important; }

  /* Issue layout: stack sidebar below */
  .issue-layout { grid-template-columns: 1fr !important; }
  .sidebar-card { position: static !important; }

  /* Form grids collapse */
  .form-grid-2 { grid-template-columns: 1fr !important; }
  .form-grid-3 { grid-template-columns: 1fr !important; }

  /* Modal fills screen */
  .modal-backdrop { padding: 8px; align-items: flex-end; }
  .modal { border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; }
}

/* ── Mobile (≤600px) ─────────────────────────────────────────────── */
@media (max-width: 600px) {

  /* Topbar: push left and right groups to edges */
  .topbar { justify-content: space-between; }
  .topbar-center { display: none; }
  .topbar-icon-btn { display: none; }
  .topbar-logo-text { display: none; } /* show only icon on very small screens */
  /* Hide hamburger on mobile — bottom nav "More" button handles the sidebar */
  .topbar-menu-btn { display: none !important; }

  /* Avatar button stays visible */
  .topbar-right { gap: 4px; }

  /* Show bottom nav */
  .bottom-nav { display: flex; }

  /* Push page content above bottom nav */
  .page-content { padding-bottom: 64px; }

  /* Page padding tighter */
  .page-pad { padding: 16px; }

  /* Page header stacks */
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-header > div:last-child { display: flex; justify-content: flex-end; }

  /* Stats row: 2x2 grid */
  .stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; }

  /* Issue row: hide some meta on tiny screens */
  .ir-labels { display: none; }
  .ir-meta .ir-meta-item:not(:last-child) { display: none; }

  /* Issue group header */
  .issue-group-header { padding: 10px 12px; }

  /* Section card less padding */
  .section-card { padding: 16px; }

  /* Filter bar: vertical stack */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .filter-group { flex-wrap: wrap; }

  /* Modal full-width */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 95vh; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* Auth card full width */
  .auth-card { border-radius: 0; min-height: 100vh; max-width: 100%; }
  .auth-form  { padding: 20px; }
  .auth-logo  { padding: 20px; }

  /* Profile/settings: full width sections */
  .profile-layout { gap: 16px; }

  /* Topbar search: full-width when open */
  .topbar-search-open {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg); z-index: 200;
    display: flex; flex-direction: column; padding: 12px;
  }

  /* Override the topbar-centric white-on-dark input styles for the mobile overlay */
  .topbar-search-open .topbar-search-input {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
  }
  .topbar-search-open .topbar-search-input::placeholder {
    color: var(--text-3);
  }
  .topbar-search-open .topbar-search-input:focus {
    background: var(--surface);
    border-color: var(--brand);
  }
  .topbar-search-open .topbar-search-icon {
    color: var(--text-3);
  }
  /* Results dropdown: not absolutely positioned in overlay — flow naturally */
  .topbar-search-open .search-results {
    position: static;
    display: block;
    margin-top: 8px;
    box-shadow: none;
    border-color: var(--border-2);
    background: var(--surface);
    flex: 1;
    overflow-y: auto;
    border-radius: var(--r-lg);
  }

  /* h1 smaller on mobile */
  h1 { font-size: 20px; }

  /* Dropdown menus full width on mobile */
  .dropdown-menu-r { left: auto; right: 0; min-width: 200px; }

  /* Buttons on mobile: slightly taller tap targets */
  .btn { min-height: 36px; }
  .btn-sm { min-height: 30px; }
}

/* ── Touch: larger tap targets ───────────────────────────────────── */
@media (pointer: coarse) {
  .filter-chip { padding: 6px 12px; }
  .dropdown-item { padding: 12px 16px; }
  .sidebar-link { padding: 10px 16px; }
  .issue-row { height: auto; min-height: 48px; padding: 10px 12px; }
  .color-swatch { width: 34px; height: 34px; }
  .form-control { min-height: 40px; }
  select.form-control { min-height: 40px; }
}

/* ── Tablet issue row: hide less important columns ───────────────── */
@media (max-width: 760px) {
  .ir-labels { display: none; }
  .search-result-project { display: none; }
}

/* ── Version chip (topbar) ──────────────────────────────────────────── */
.topbar-version {
  font-size: 11px; font-weight: 600; font-family: var(--mono);
  color: rgba(255,255,255,.45);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px; padding: 2px 8px;
  flex-shrink: 0; white-space: nowrap;
  transition: color var(--t-fast);
}
.topbar-version:hover { color: rgba(255,255,255,.75); }
@media (max-width: 600px) { .topbar-version { display: none; } }



/* ============================================================
   THEME SYSTEM — Light / Dark / OLED
   data-theme="light"  → forced light
   data-theme="dark"   → forced dark
   data-theme="oled"   → forced OLED black
   no attribute        → follows OS via prefers-color-scheme
============================================================ */

/* ── Smooth transition when switching themes ─────────────────── */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color 350ms ease,
    background       350ms ease,
    color            350ms ease,
    border-color     350ms ease,
    box-shadow       350ms ease !important;
}

/* ── Dark variables — explicit data-theme="dark" ─────────────── */
[data-theme="dark"] {
  --text:     #c7d1e0;
  --text-2:   #8c9ab0;
  --text-3:   #5a6478;
  --border:   #2d3447;
  --border-2: #232938;
  --bg:       #161b27;
  --surface:  #1e2535;
  --gray-50:  #1a1f2e;
  --gray-100: #1e2535;
  --gray-200: #232938;
  --gray-300: #2d3447;
  --gray-400: #3d4861;
  --gray-500: #5a6478;
  --gray-600: #7a8599;
  --gray-700: #8c9ab0;
  --gray-800: #a8b4c8;
  --gray-900: #c7d1e0;
  --gray-950: #e8ecf3;
  --brand:       #4c9aff;
  --brand-hover: #2684ff;
  --brand-light: #0d2d5e;
  --topbar-bg:   #0d1117;
  --danger-bg:   #2d1a1a;
  --danger-border: #5c2a2a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 3px 8px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.6);
  --shadow-xl: 0 20px 64px rgba(0,0,0,.7);
  color-scheme: dark;
}

/* ── Dark variables — OS system preference ───────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="oled"]) {
    --text:     #c7d1e0;
    --text-2:   #8c9ab0;
    --text-3:   #5a6478;
    --border:   #2d3447;
    --border-2: #232938;
    --bg:       #161b27;
    --surface:  #1e2535;
    --gray-50:  #1a1f2e;
    --gray-100: #1e2535;
    --gray-200: #232938;
    --gray-300: #2d3447;
    --gray-400: #3d4861;
    --gray-500: #5a6478;
    --gray-600: #7a8599;
    --gray-700: #8c9ab0;
    --gray-800: #a8b4c8;
    --gray-900: #c7d1e0;
    --gray-950: #e8ecf3;
    --brand:       #4c9aff;
    --brand-hover: #2684ff;
    --brand-light: #0d2d5e;
    --topbar-bg:   #0d1117;
    --danger-bg:   #2d1a1a;
    --danger-border: #5c2a2a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 3px 8px rgba(0,0,0,.5);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.6);
    --shadow-xl: 0 20px 64px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}

/* ── OLED variables — pure black ─────────────────────────────── */
[data-theme="oled"] {
  --text:     #e8ecf3;
  --text-2:   #8c9ab0;
  --text-3:   #4a5568;
  --border:   #1a1a1a;
  --border-2: #111111;
  --bg:       #000000;
  --surface:  #0a0a0a;
  --gray-50:  #050505;
  --gray-100: #0a0a0a;
  --gray-200: #111111;
  --gray-300: #1a1a1a;
  --gray-400: #262626;
  --gray-500: #404040;
  --gray-600: #595959;
  --gray-700: #737373;
  --gray-800: #a0a0a0;
  --gray-900: #d4d4d4;
  --gray-950: #f0f0f0;
  --brand:       #4c9aff;
  --brand-hover: #2684ff;
  --brand-light: #051429;
  --topbar-bg:   #000000;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.8);
  --shadow-md: 0 3px 8px rgba(0,0,0,.9);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.95);
  --shadow-xl: 0 20px 64px rgba(0,0,0,1);
  color-scheme: dark;
}

/* ── Theme toggle button ─────────────────────────────────────── */
.theme-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: transparent; border: none;
  border-radius: var(--r-md); color: rgba(255,255,255,.7); cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.theme-toggle-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.theme-toggle-btn svg { width: 17px; height: 17px; }

/* ── Theme picker dropdown ───────────────────────────────────── */
.theme-picker {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-xl);
  padding: 6px; min-width: 160px; z-index: 500; display: none;
}
.theme-picker.show { display: block; }
.theme-picker-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; background: none; border: none;
  border-radius: var(--r-md); font-family: var(--font); font-size: 13px;
  color: var(--text); cursor: pointer; text-align: left;
  transition: background var(--t-fast);
}
.theme-picker-item:hover { background: var(--gray-100); }
.theme-picker-item.active { color: var(--brand); font-weight: 500; }
.theme-picker-item.active .theme-picker-check { opacity: 1; }
.theme-picker-check { margin-left: auto; opacity: 0; color: var(--brand); }
.theme-picker-swatch {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0;
}
