:root {
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-subtle: #f1f5f9;
    --bg-unread: #eff6ff;
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-light: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #dc2626;
    --focus-ring: #2563eb;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
}

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--bg-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--primary);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    z-index: 1000;
    text-decoration: none;
    font-weight: 600;
}

.skip-link:focus {
    top: 12px;
}

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

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

a:hover {
    text-decoration: underline;
}

.topbar {
    background: #0f172a;
    color: #f8fafc;
    border-bottom: 1px solid #1e293b;
}

.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}

.brand-logo:hover {
    text-decoration: none;
}

.brand-badge {
    background: var(--primary);
    color: #ffffff;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}

.project-switcher select {
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.9rem;
}

.quick-search {
    flex: 1 1 280px;
    max-width: 460px;
}

.quick-search input {
    width: 100%;
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    font-size: 0.9rem;
}

.quick-search input::placeholder {
    color: #94a3b8;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    background: #1e293b;
    color: #e2e8f0;
    font-size: 0.88rem;
}

.badge-admin {
    background: #7c3aed;
    color: #ffffff;
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.main-nav {
    background: #1e293b;
    border-top: 1px solid #334155;
}

.nav-list {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    list-style: none;
    display: flex;
    gap: 4px;
    overflow-x: auto;
}

.nav-list a {
    display: block;
    padding: 10px 14px;
    color: #cbd5e1;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.nav-list a:hover {
    color: #ffffff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
}

.nav-list a.active {
    color: #ffffff;
    border-bottom-color: #3b82f6;
    background: rgba(59, 130, 246, 0.12);
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-header h1 {
    margin: 0 0 4px 0;
    font-size: 1.55rem;
}

.page-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card h2 {
    margin-top: 0;
    font-size: 1.15rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-header h2 {
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

.stat-highlight {
    border-left: 4px solid var(--primary);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.stat-desc {
    font-size: 0.82rem;
    color: var(--text-light);
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
}

.grid-two {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.table th,
.table td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-subtle);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.issue-row-unread {
    background-color: var(--bg-unread);
}

.issue-row-unread .issue-title-link,
.issue-row-unread .issue-key {
    font-weight: 700;
    color: #0f172a;
}

.issue-row-closed {
    opacity: 0.68;
}

.issue-row-closed .issue-title-link {
    text-decoration: line-through;
}

.unread-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary);
    margin-right: 6px;
    vertical-align: middle;
}

.issue-key {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.86rem;
    color: var(--text-muted);
}

.issue-title-link {
    color: var(--text-main);
    font-weight: 500;
    display: inline-block;
}

.issue-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    display: flex;
    gap: 6px;
    margin-top: 2px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--border-strong);
    background: var(--bg-subtle);
}

.status-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    color: #ffffff;
}

.priority-label {
    font-weight: 600;
    font-size: 0.85rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 15px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--bg-subtle);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-ghost {
    background: transparent;
    color: inherit;
    border-color: rgba(148, 163, 184, 0.3);
}

.btn-ghost:hover {
    background: rgba(148, 163, 184, 0.12);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.82rem;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 0.76rem;
}

.btn-block {
    width: 100%;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: inherit;
    background: #ffffff;
    color: var(--text-main);
}

.form-group input:disabled {
    background: var(--bg-subtle);
    color: var(--text-light);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.full-width {
    grid-column: 1 / -1;
}

.auth-wrapper {
    display: flex;
    justify-content: center;
    padding: 32px 0;
}

.auth-card {
    width: 100%;
    max-width: 440px;
}

.auth-card-wide {
    max-width: 780px;
}

.card-header {
    margin-bottom: 20px;
}

.card-header h1 {
    margin: 0 0 6px 0;
    font-size: 1.4rem;
}

.setup-steps {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setup-step {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    background: var(--bg-subtle);
}

.step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.step-header h2 {
    margin: 0;
    font-size: 1.05rem;
    flex: 1;
}

.step-badge {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #ffffff;
    background: var(--primary);
}

.badge-success { background: var(--success); }
.badge-warning { background: var(--warning); }
.badge-danger { background: var(--danger); }
.badge-primary { background: var(--primary); }

.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-ok {
    background: #dcfce7;
    color: #166534;
}

.status-warn {
    background: #fef3c7;
    color: #92400e;
}

.status-err {
    background: #fee2e2;
    color: #991b1b;
}

.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-color: #bfdbfe;
}

.project-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.project-item {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.project-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.project-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.module-tags {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.module-tag {
    display: inline-block;
    padding: 3px 9px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-main);
}

.module-tag:hover {
    background: #e2e8f0;
    text-decoration: none;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 900;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    max-width: 480px;
    width: 100%;
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.15rem;
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 16px;
    margin: 0;
    align-items: center;
}

.shortcuts-grid dd {
    margin: 0;
    color: var(--text-muted);
}

kbd {
    background: var(--bg-subtle);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.8rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.footer {
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    margin-top: 40px;
}

.footer-inner {
    padding-top: 14px;
    padding-bottom: 14px;
    display: flex;
    justify-content: space-between;
    color: var(--text-light);
    font-size: 0.84rem;
    flex-wrap: wrap;
    gap: 8px;
}

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.84rem; }
.nowrap { white-space: nowrap; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.empty-state {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
}
