:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-soft: #eef5f2;
  --surface-warm: #fff8ea;
  --border: #dfe7e3;
  --border-strong: #b9cbc4;
  --text: #17231f;
  --muted: #62736d;
  --primary: #1f6f68;
  --primary-dark: #15534d;
  --primary-soft: #e4f3f0;
  --accent: #d9862b;
  --accent-soft: #fff0dc;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --success: #167245;
  --success-soft: #e9f8ef;
  --shadow: 0 14px 35px rgba(22, 35, 31, 0.08);
  --radius: 8px;
  --sidebar: 248px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
  overflow-x: hidden;
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

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

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-panel {
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin-bottom: 10px;
}

.auth-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.auth-message {
  margin-top: 14px;
  color: var(--danger);
  line-height: 1.55;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  background: #123b37;
  color: #effaf7;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  min-height: 40px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #b9d3cd;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #dcece8;
  text-align: left;
}

.nav-button:hover,
.nav-button.is-active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 22px 28px 36px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

h3 {
  margin-bottom: 6px;
  font-size: 15px;
}

.topbar-actions,
.row-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.session-badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
}

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

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

.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  background: var(--surface-soft);
}

.ghost-button {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
}

.icon-button {
  width: 36px;
  padding: 0;
}

svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.controls,
.panel,
.metric,
.list-item,
.timeline-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 180px;
  gap: 10px;
  padding: 12px;
  margin-bottom: 18px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--text);
}

textarea {
  min-height: 82px;
  padding-top: 9px;
  resize: vertical;
}

.view-root {
  display: grid;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(340px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

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

.panel-header p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: #f9fbfa;
}

td {
  line-height: 1.45;
}

.cell-title {
  font-weight: 800;
}

.cell-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.is-warning {
  background: var(--accent-soft);
  color: #875315;
}

.badge.is-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge.is-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  padding: 12px;
}

.list-item p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.list-item__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 7px;
}

.issue-details {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.issue-details summary {
  cursor: pointer;
  font-weight: 800;
}

.issue-details ul {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.6;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  padding: 12px;
  display: grid;
  gap: 5px;
}

.timeline-item small {
  color: var(--muted);
}

.pipeline {
  display: grid;
  gap: 9px;
}

.pipeline-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) 54px;
  gap: 10px;
  align-items: center;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #e6eeeb;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.kanban-column {
  min-width: 220px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fbfa;
}

.kanban-column h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.empty {
  padding: 18px;
  border-radius: 8px;
  background: #f9fbfa;
  color: var(--muted);
  text-align: center;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(105%);
  transition: transform 180ms ease;
  z-index: 20;
  padding: 18px;
  overflow-y: auto;
}

.detail-drawer.is-open {
  transform: translateX(0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 35, 31, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 19;
}

.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  min-width: 240px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #102e2b;
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: 160ms ease;
  z-index: 30;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .nav-button {
    width: auto;
    white-space: nowrap;
  }

  .metric-grid,
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar,
  .panel-header,
  .notice {
    display: grid;
  }

  .controls,
  .metric-grid,
  .grid-3,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .kanban {
    grid-template-columns: 1fr;
  }

  .notice,
  .list-item,
  .panel,
  td,
  th {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}
