:root {
  --navy: #0a1e3f;
  --navy-2: #142f5a;
  --accent: #2757b8;
  --accent-dark: #1a3d88;
  --gold: #d4af37;
  --bg: #eef2f8;
  --surface: #ffffff;
  --ink: #1f2840;
  --muted: #677289;
  --line: #d2dae5;
  --head: #f4f7fb;
  --overdue: #b54545;
  --waiting: #b4801a;
  --done: #1f7a4d;
  --request: #5b4db5;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 650; }
p { margin: 0; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  flex: none;
  background: var(--navy);
  color: #d7e2f5;
}
.brand {
  display: block;
  padding: 16px 18px;
  color: white;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-bottom: 3px solid var(--gold);
  text-decoration: none;
}
.brand:hover { color: white; text-decoration: none; }
.sidebar nav { display: flex; flex-direction: column; padding: 10px 0 24px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 18px;
  color: #d7e2f5;
  text-decoration: none;
}
.sidebar nav a:hover { background: var(--navy-2); color: white; }
.sidebar nav a.on { background: var(--accent); color: white; }
.nav-label {
  margin: 14px 18px 4px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #8ea4c8;
}
.count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--overdue);
  color: white;
  font-size: 0.72rem;
  display: inline-grid;
  place-items: center;
}

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 8px 20px;
  background: linear-gradient(90deg, #16265c 0%, #1e3f8f 45%, #2757b8 100%);
  color: white;
}
.group-form, .account { display: flex; align-items: center; gap: 8px; }
.group-form label, .account small { color: #d7e2f5; font-size: 0.8rem; }
.navbar select, .navbar button {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border-radius: 2px;
  padding: 5px 10px;
}
.navbar select option { color: var(--ink); }
.account small { display: block; }
.account span { font-weight: 650; }

main { padding: 16px 20px 32px; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.page-head h1 { font-size: 1.25rem; color: var(--navy-2); }
.page-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 2px; font-size: 0.8rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  margin-bottom: 14px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--head);
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 0.95rem; color: var(--accent); }
.panel-body { padding: 12px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  padding: 10px 12px;
  color: inherit;
  text-decoration: none;
}
.kpi:hover { text-decoration: none; background: var(--head); }
.kpi b { display: block; font-size: 1.6rem; line-height: 1.1; color: var(--navy); }
.kpi small { color: var(--muted); }
.kpi.overdue { border-left-color: var(--overdue); }
.kpi.request { border-left-color: var(--request); }
.kpi.waiting { border-left-color: var(--waiting); }

.toolbar { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar a, .text-link, .quiet-btn, .primary, button, .danger {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 2px;
  padding: 5px 12px;
  text-decoration: none;
  font-weight: 650;
}
.toolbar a.on, .primary, .status-row button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.primary:hover, .toolbar a.on:hover { background: var(--accent-dark); }
.text-link, .quiet-btn { color: var(--accent); background: white; }
.danger { color: var(--overdue); border-color: #e4c4c4; }
.toolbar a:hover, .text-link:hover { text-decoration: none; }

table.data, table.form {
  width: 100%;
  border-collapse: collapse;
  background: white;
}
table.data th, table.data td, table.form th, table.form td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  vertical-align: middle;
  text-align: left;
}
table.data th {
  background: var(--head);
  color: var(--accent);
  font-weight: 650;
  white-space: nowrap;
}
table.data tr:nth-child(even) td { background: #f8fafd; }
table.data tr.is-done td { color: var(--muted); }
table.data tr.is-done a { color: var(--muted); }
table.form th {
  width: 180px;
  background: var(--head);
  font-weight: 650;
  white-space: nowrap;
}
.empty { padding: 16px; color: var(--muted); text-align: center; }

input, select, textarea {
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 2px;
  padding: 6px 8px;
}
textarea { max-width: none; resize: vertical; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline select, .inline input { width: auto; min-width: 180px; }
.form-actions { margin-top: 12px; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 450; }
.checkline input { width: auto; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border: 1px solid var(--line); position: relative; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.swatch:has(input:checked) { outline: 2px solid var(--navy); }

.meta, small, .quiet { color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 8px; }
.body { white-space: pre-wrap; }
.overdue { color: var(--overdue); font-weight: 700; }
.request { color: var(--request); }
.pill {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--line);
  background: var(--head);
  font-size: 0.78rem;
  white-space: nowrap;
}
.pill.waiting, .status-WAITING { color: var(--waiting); border-color: #ead7a8; background: #fff8ea; }
.status-DONE { color: var(--done); border-color: #b7e0cb; background: #eef8f3; }
.status-IN_PROGRESS { color: var(--accent); border-color: #c5d4f2; background: #eef3fc; }
.prio.HIGH { color: var(--overdue); border-color: #e4c4c4; background: #fdf4f4; }
.status-row { display: flex; flex-wrap: wrap; gap: 6px; }
.status-row form { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.comment + .comment, .file-row + .file-row { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.file-row, .member { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.flashes { margin-bottom: 12px; }
.flash { margin: 0 0 8px; padding: 8px 12px; border: 1px solid #e4c4c4; background: #fdf4f4; color: #8d2e2e; }
.flash.success { border-color: #b7e0cb; background: #eef8f3; color: var(--done); }
.notice.unread strong { color: var(--accent-dark); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.login {
  width: min(420px, calc(100% - 32px));
  background: white;
  border: 1px solid var(--line);
  border-top: 4px solid var(--navy);
}
.login-head {
  padding: 18px 20px 12px;
  background: var(--navy);
  color: white;
}
.login-head h1 { font-size: 1.35rem; }
.login-head p { margin-top: 4px; color: #d7e2f5; font-size: 0.85rem; }
.login .stack { padding: 18px 20px 8px; }
.login label { display: block; margin-bottom: 4px; font-weight: 650; }
.login input { max-width: none; margin-bottom: 12px; }
.login .primary { width: 100%; padding: 8px 12px; }
.switch { display: block; padding: 4px 20px 16px; font-size: 0.85rem; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; padding: 6px; }
  .nav-label { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; }
  table.form th { width: 110px; }
}
