:root {
  --bg-app: #0f172a;
  --bg-surface: #1e293b;
  --bg-elevated: #334155;
  --bg-input: #0f172a;
  --border-color: #334155;
  --border-subtle: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --radius: 8px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px 24px 48px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

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

.view-switcher {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 3px;
}

.view-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}

.view-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

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

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

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

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-color);
}

.btn-ghost:hover {
  color: var(--text-main);
  background: var(--bg-surface);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
}

/* Summary / Type Filter Cards */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.type-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  color: var(--text-main);
  transition: all 0.15s;
}

.type-card:hover {
  border-color: #64748b;
  transform: translateY(-1px);
}

.type-card.active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 0 0 1px var(--accent);
}

.type-icon {
  font-size: 22px;
}

.type-meta {
  display: flex;
  flex-direction: column;
}

.type-label {
  font-size: 12px;
  color: var(--text-muted);
}

.type-count {
  font-size: 20px;
  font-weight: 700;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  background: var(--bg-surface);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.search-box {
  flex: 1 1 280px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 13px;
}

.filter-selects {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

select,
input[type="text"],
input[type="password"],
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Table View */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow-x: auto;
}

.issues-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.issues-table th {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.issues-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  vertical-align: middle;
}

.issues-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.issues-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.08);
}

.issue-row-title {
  font-weight: 600;
  color: var(--text-main);
  display: block;
  margin-bottom: 3px;
}

.issue-row-snippet {
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-type-Bug {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.badge-type-Task {
  background: rgba(59, 130, 246, 0.16);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.badge-type-Feature {
  background: rgba(168, 85, 247, 0.16);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.35);
}
.badge-type-Knowhow {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-status-Open {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}
.badge-status-InProgress {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}
.badge-status-Resolved {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}
.badge-status-Closed {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}

.project-pill {
  background: rgba(148, 163, 184, 0.12);
  color: #e2e8f0;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.triage-group {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.triage-pill {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.level-High {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}
.level-Medium,
.level-Normal {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
}
.level-Low {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

/* Kanban Board */
.kanban-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: start;
}

.kanban-column {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.kanban-col-header {
  padding: 12px 14px;
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-count {
  background: rgba(15, 23, 42, 0.6);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.kanban-list {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.kanban-list.drag-over {
  background: rgba(59, 130, 246, 0.1);
}

.kanban-card {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 7px;
  padding: 12px;
  cursor: grab;
  transition: transform 0.12s, border-color 0.12s;
}

.kanban-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.kanban-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 6px;
}

.kanban-card-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  line-height: 1.4;
}

.kanban-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(51, 65, 85, 0.45);
  font-size: 11px;
  color: var(--text-muted);
}

/* Detail Drawer */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(820px, 95vw);
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.drawer-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.drawer-id-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.issue-id-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg-app);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: #93c5fd;
  border: 1px solid var(--border-color);
}

.drawer-dates {
  font-size: 12px;
  color: var(--text-muted);
}

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

.drawer-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.drawer-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 18px;
  line-height: 1.35;
}

.props-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: var(--bg-app);
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.prop-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prop-item label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Markdown Body Styling (Crucial for reading logs & docs) */
.markdown-section {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.section-header {
  padding: 10px 16px;
  background: rgba(30, 41, 59, 0.7);
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.markdown-body {
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  color: #e2e8f0;
  overflow-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin-top: 16px;
  margin-bottom: 8px;
  color: #fff;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
  padding-bottom: 4px;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
  margin-bottom: 12px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 22px;
}

.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(51, 65, 85, 0.65);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  color: #f8fafc;
}

.markdown-body pre {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 14px;
  overflow-x: auto;
  margin-bottom: 14px;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.5;
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Forms & Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  width: min(680px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-sm {
  width: min(440px, 100%);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer,
.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

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

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.helper-text {
  font-size: 12.5px;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #10b981;
  color: #052e16;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 80;
}

@media (max-width: 1024px) {
  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .kanban-container {
    grid-template-columns: repeat(2, 1fr);
  }
  .props-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-row-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}
