:root {
  color-scheme: light;
  --bg: #eff3f8;
  --panel: #ffffff;
  --panel-soft: #f6f8fc;
  --panel-ink: #0f172a;
  --text: #1f2937;
  --muted: #566173;
  --line: #d8e0ea;
  --line-strong: #c2cfdd;
  --accent: #1e4fa6;
  --accent-strong: #173f86;
  --accent-soft: #e1ebff;
  --warning: #92400e;
  --warning-soft: #ffedd5;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --success: #166534;
  --success-soft: #dcfce7;
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --sidebar-width: 280px;
  --topbar-height: 76px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

img {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111b30 100%);
  color: #e5e7eb;
  padding: 1.3rem 1.1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0 0.4rem 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-subtitle {
  color: #94a3b8;
  font-size: 0.93rem;
}

.sidebar-nav,
.sidebar-section,
.topbar-actions,
.stat-grid,
.section-grid,
.project-grid,
.ticket-cards,
.activity-list,
.timeline,
.link-list,
.detail-grid,
.meta-grid,
.summary-list {
  display: grid;
  gap: 0.75rem;
}

.sidebar-nav {
  gap: 0.3rem;
}

.sidebar-nav a,
.sidebar-nav summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: #e5e7eb;
  padding: 0.74rem 0.82rem;
  border-radius: 10px;
  font-weight: 650;
  border: 1px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav summary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.sidebar-nav a.active,
.sidebar-nav summary.active {
  background: rgba(30, 79, 166, 0.34);
  border-color: rgba(147, 197, 253, 0.35);
  color: #fff;
}

.sidebar-subnav {
  display: grid;
  gap: 0.2rem;
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-subnav a {
  font-size: 0.94rem;
  color: #cbd5e1;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 0.75rem;
}

.user-chip,
.pill,
.status-pill,
.priority-pill,
.result-pill,
.count-pill,
.link-pill,
.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.user-chip {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.count-pill,
.meta-pill {
  background: var(--panel-soft);
  color: var(--muted);
}

.status-pill,
.priority-pill,
.result-pill,
.link-pill {
  border: 1px solid transparent;
}

.pill-accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.pill-success,
.status-done,
.result-done {
  background: var(--success-soft);
  color: var(--success);
}

.pill-warning,
.status-waiting,
.status-blocked {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-ready,
.priority-p0,
.priority-p1 {
  background: #dbeafe;
  color: #1d4ed8;
}

.priority-p2,
.priority-p3,
.status-backlog,
.status-cancelled {
  background: #e5e7eb;
  color: #374151;
}

.layout {
  display: block;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line-strong);
  background: rgba(248, 250, 253, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-main {
  display: grid;
  gap: 0.2rem;
}

.topbar-title {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--panel-ink);
}

.topbar-description {
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-actions {
  grid-auto-flow: column;
  align-items: center;
  gap: 0.75rem;
}

.topbar-search {
  min-width: min(34vw, 380px);
}

.topbar-search form {
  display: flex;
  gap: 0.45rem;
}

.topbar-search input {
  padding-block: 0.7rem;
}

.auth-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.auth-link {
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
}

.content {
  padding: 1.2rem 1.25rem 1.5rem;
  min-width: 0;
}

.content-inner {
  width: 100%;
  margin-inline: auto;
  display: grid;
  gap: 0.9rem;
}

.surface,
.stat-card,
.panel,
.ticket-card,
.project-card,
.timeline-item,
.detail-section,
.filter-panel,
.list-shell,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.surface,
.panel,
.detail-section,
.filter-panel,
.list-shell {
  padding: 1rem 1.05rem;
}

.stat-grid,
.section-grid,
.project-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat-card,
.project-card,
.ticket-card,
.timeline-item {
  padding: 1rem;
}

.stat-label,
.section-label,
.card-label,
.meta-label,
.field-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 2rem;
  font-weight: 850;
  line-height: 1.1;
  margin-top: 0.2rem;
}

.stat-note,
.card-note,
.empty-state,
.help-text,
.meta-value {
  color: var(--muted);
}

.page-hero {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.page-title {
  font-size: clamp(1.55rem, 2.5vw, 2rem);
  margin: 0;
  color: var(--panel-ink);
}

.page-description {
  margin: 0;
  color: var(--muted);
  max-width: 70ch;
}

.hero-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.hero-actions,
.filter-actions,
.sort-pills,
.ticket-tags,
.detail-tags,
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.filter-panel {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line-strong);
}

.filter-grid,
.detail-grid,
.meta-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field-label {
  color: var(--muted);
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.button-secondary,
.button-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.72rem 0.95rem;
  border-radius: 12px;
  font-weight: 700;
}

.button-secondary {
  background: var(--panel-soft);
  color: var(--text);
  border: 1px solid var(--line);
}

.button-secondary:hover,
.button-ghost:hover {
  text-decoration: none;
  filter: brightness(0.98);
}

.button-ghost {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid var(--accent-soft);
}

.table-shell {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--panel);
}

.work-table,
.ticket-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.work-table th,
.work-table td,
.ticket-table th,
.ticket-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #e6ebf2;
  vertical-align: top;
}

.work-table th,
.ticket-table th {
  background: #f4f7fc;
  text-align: left;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}

.work-table tbody tr:nth-child(even) td,
.ticket-table tbody tr:nth-child(even) td {
  background: #fbfcff;
}

.work-table tr:hover td,
.ticket-table tr:hover td {
  background: #f2f6fc;
}

.ticket-number {
  font-weight: 800;
  color: var(--panel-ink);
}

.ticket-id-link,
.summary-link {
  color: var(--accent-strong);
  font-weight: 700;
}

.summary-link {
  color: var(--panel-ink);
}

.ticket-id-link:hover,
.summary-link:hover {
  text-decoration: underline;
}

.ticket-cell-main {
  min-width: 290px;
}

.ticket-cell-badge,
.ticket-cell-project,
.ticket-cell-owner,
.ticket-cell-updated {
  white-space: nowrap;
}

.ticket-cell-action {
  min-width: 260px;
}

.ticket-summary {
  font-weight: 650;
  margin-top: 0.25rem;
}

.ticket-subtext,
.ticket-mini,
.activity-meta,
.detail-meta,
.list-meta,
.project-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.ticket-cards {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.ticket-card,
.project-card {
  display: grid;
  gap: 0.75rem;
}

.ticket-card header,
.project-card header,
.detail-section header {
  display: grid;
  gap: 0.35rem;
}

.ticket-card .summary,
.project-card .summary,
.detail-summary {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--panel-ink);
  margin: 0;
}

.ticket-card .body,
.project-card .body,
.detail-body {
  color: var(--text);
}

.ticket-card .footer,
.project-card .footer,
.detail-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.dashboard-hero {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.dashboard-grid {
  align-items: start;
}

.panel-state {
  border-left: 4px solid var(--line-strong);
}

.panel-attention {
  border-left-color: #1d4ed8;
}

.panel-active {
  border-left-color: #0f766e;
}

.panel-blocked {
  border-left-color: #b45309;
}

.panel-recent {
  border-left-color: #4338ca;
}

.panel-projects {
  border-left-color: #475569;
}

.dashboard-intro {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}

.dashboard-intro .panel {
  min-height: 100%;
}

.empty-state {
  padding: 1rem;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: var(--panel-soft);
}

.timeline {
  gap: 0.9rem;
}

.timeline-item {
  display: grid;
  gap: 0.5rem;
  border-left: 3px solid #dbe5f2;
  border-radius: 12px;
}

.timeline-header,
.detail-grid-item,
.summary-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.detail-hero {
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 249, 255, 0.98));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.detail-heading {
  display: grid;
  gap: 0.5rem;
}

.detail-kicker {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-title {
  margin: 0;
  font-size: clamp(1.45rem, 2.8vw, 2rem);
  color: var(--panel-ink);
}

.detail-record {
  display: grid;
  gap: 0.9rem;
}

.detail-header {
  display: grid;
  gap: 0.45rem;
  padding: 1.05rem 1.1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 249, 255, 0.98));
  box-shadow: var(--shadow);
}

.detail-id {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.next-action-highlight {
  border: 1px solid #bfdbfe;
  border-left: 5px solid #2563eb;
  border-radius: var(--radius-lg);
  padding: 0.9rem 1rem;
  background: #eff6ff;
}

.next-action-highlight h2,
.narrative-section h2,
.compact-details h2 {
  margin: 0 0 0.55rem;
  color: var(--panel-ink);
  font-size: 1.05rem;
}

.narrative-section {
  display: grid;
  gap: 0.45rem;
  padding: 1rem 1.05rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.compact-details {
  padding: 1rem 1.05rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.detail-list {
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid #edf2f7;
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-row dt,
.detail-row dd {
  margin: 0;
}

.detail-row-multi dd {
  display: grid;
  gap: 0.2rem;
}

.detail-sections {
  margin-top: 1rem;
  align-items: start;
}

.detail-section {
  display: grid;
  gap: 0.5rem;
}

.detail-section-wide {
  grid-column: 1 / -1;
}

.detail-grid-item {
  display: grid;
  gap: 0.35rem;
  align-content: start;
}

.field-value,
.detail-value,
.ticket-body,
.activity-body,
.project-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.prose-block {
  display: grid;
  gap: 0.35rem;
}

.subsection-title {
  margin: 0;
  font-size: 1.12rem;
  color: var(--panel-ink);
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e8edf5;
}

.section-heading h2,
.section-heading h3,
.section-heading p {
  margin: 0;
}

.section-heading h2 {
  font-size: 1.05rem;
}

.link-list {
  gap: 0.65rem;
}

.inline-link-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.2rem;
}

.table-shell {
  overflow-x: auto;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.activity-table th,
.activity-table td {
  vertical-align: top;
  text-align: left;
  padding: 0.6rem 0.55rem;
  border-bottom: 1px solid #e5e7eb;
}

.activity-table th {
  font-size: 0.85rem;
  color: var(--muted);
}

.activity-cell-time {
  white-space: nowrap;
}

.activity-cards {
  display: grid;
  gap: 0.55rem;
}

.activity-card {
  padding: 0.75rem 0.8rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: var(--panel-soft);
  display: grid;
  gap: 0.25rem;
}

.link-item,
.summary-item {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid #e5e7eb;
}

.link-title,
.summary-title {
  font-weight: 750;
  color: var(--panel-ink);
}

.link-url {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(100%, 460px);
  padding: 1.4rem;
}

.login-card h1 {
  margin: 0 0 0.35rem;
  color: var(--panel-ink);
}

.login-card p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 0.85rem;
}

.login-form label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 700;
}

.login-form .errorlist {
  margin: 0;
  padding-left: 1rem;
  color: var(--danger);
}

.mobile-nav,
.mobile-only {
  display: none;
}

@media (max-width: 1080px) {
  .sidebar {
    padding: 1rem 0.8rem;
  }
}

@media (max-width: 760px) {
  .content {
    padding: 0.9rem;
  }

  .content-inner {
    width: 100%;
  }

  .sidebar {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-nav {
    display: block;
    margin-bottom: 0.8rem;
  }

  .mobile-nav summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.95rem 1rem;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    cursor: pointer;
    font-weight: 800;
  }

  .mobile-nav summary::-webkit-details-marker {
    display: none;
  }

  .mobile-nav-panel {
    margin-top: 0.6rem;
    padding: 0.8rem;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
  }

  .mobile-nav-panel .sidebar-nav,
  .mobile-nav-panel .sidebar-subnav {
    display: grid;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .topbar-search {
    width: 100%;
    min-width: 0;
  }

  .topbar-actions {
    width: 100%;
    grid-auto-flow: row;
    justify-content: stretch;
  }

  .auth-actions {
    justify-content: space-between;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: grid;
  }

  .ticket-table {
    min-width: 0;
  }

  .work-table {
    min-width: 640px;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}
