:root {
  --bg: #f4f1ea;
  --ink: #1c2522;
  --muted: #68736e;
  --line: #d9d0c3;
  --panel: #fffaf1;
  --panel-strong: #f7ead7;
  --green: #1f7a5c;
  --teal: #176d78;
  --red: #b64236;
  --amber: #b66b18;
  --blue: #365fa9;
  --shadow: 0 18px 50px rgba(61, 49, 31, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(28, 37, 34, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(28, 37, 34, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

body.is-locked {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(54, 95, 169, 0.36);
  outline-offset: 2px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 10%, rgba(225, 183, 93, 0.35), transparent 34%),
    radial-gradient(circle at 82% 18%, rgba(23, 109, 120, 0.22), transparent 30%),
    var(--bg);
}

.login-screen.is-hidden {
  display: none;
}

.login-card {
  width: min(560px, 100%);
  padding: 28px;
  background: rgba(255, 250, 241, 0.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand.large .brand-mark {
  width: 54px;
  height: 54px;
}

.login-card h1 {
  margin: 22px 0 10px;
  font-size: clamp(28px, 6vw, 44px);
  line-height: 1.15;
}

.login-form,
.stack-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.login-form label,
.stack-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.role-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.role-picker label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
}

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

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: #1d2d29;
  color: #fffaf1;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 250, 241, 0.34);
  background: #e1b75d;
  color: #1d2d29;
  font-weight: 800;
}

.brand p,
.brand span,
.sidebar-note p,
.eyebrow {
  margin: 0;
}

.brand p {
  font-weight: 800;
  letter-spacing: 0;
}

.brand span {
  color: rgba(255, 250, 241, 0.7);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  color: rgba(255, 250, 241, 0.78);
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
}

.nav-item:hover,
.nav-item.is-active {
  color: #fffaf1;
  background: rgba(255, 250, 241, 0.12);
}

.sidebar-note {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(255, 250, 241, 0.18);
  background: rgba(255, 250, 241, 0.08);
  border-radius: 8px;
}

.sidebar-note p {
  margin-top: 8px;
  color: rgba(255, 250, 241, 0.72);
  font-size: 13px;
  line-height: 1.7;
}

.main {
  padding: 28px;
}

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

.topbar h1 {
  max-width: 880px;
  margin: 6px 0 0;
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1.12;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.user-chip {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  max-width: 240px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.8);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.ghost-button,
.icon-button,
.segment {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  background: var(--panel);
  color: var(--ink);
}

.primary-button {
  border-color: #1d2d29;
  background: #1d2d29;
  color: #fffaf1;
  font-weight: 800;
}

.primary-button.full {
  width: 100%;
  margin: 12px 0;
}

.ghost-button:hover,
.icon-button:hover,
.segment:hover {
  background: var(--panel-strong);
}

.icon-button {
  width: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 20px;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

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

.metric,
.panel {
  background: rgba(255, 250, 241, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.metric {
  grid-column: span 3;
  padding: 18px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin: 8px 0;
  font-size: 34px;
}

.panel {
  padding: 18px;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

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

.panel h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #efe4d3;
}

.segment {
  min-height: 34px;
  border: 0;
  background: transparent;
  font-size: 13px;
}

.segment.is-active {
  background: var(--panel);
  box-shadow: 0 6px 16px rgba(61, 49, 31, 0.12);
}

.ticket-board,
.member-list,
.daily-list,
.report-list,
.request-table,
.people-grid,
.approval-list,
.audit-list,
.user-table {
  display: grid;
  gap: 12px;
}

.ticket-card,
.member-row,
.daily-row,
.report-card,
.request-row,
.person-card,
.approval-card,
.audit-row,
.user-row {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 8px;
  padding: 14px;
}

.ticket-card {
  display: grid;
  gap: 10px;
}

.ticket-top,
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.ticket-title {
  margin: 0;
  font-weight: 800;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge,
.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #e8eadf;
  color: #335045;
}

.status-pill.private {
  background: #eadfea;
  color: #69426a;
}

.badge.high,
.badge.risk {
  background: #f3d8d3;
  color: var(--red);
}

.badge.medium {
  background: #f5e3c8;
  color: var(--amber);
}

.badge.low {
  background: #dce9ec;
  color: var(--teal);
}

.badge.done {
  background: #dceadd;
  color: var(--green);
}

.progress-track {
  height: 9px;
  overflow: hidden;
  background: #ece1d1;
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--green), #e1b75d);
}

.member-row {
  display: grid;
  grid-template-columns: minmax(100px, 150px) 1fr auto;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1d2d29;
  color: #fffaf1;
  font-weight: 800;
}

.person-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.ai-report {
  border-left: 4px solid var(--green);
  background: #eef4ea;
  padding: 16px;
  border-radius: 0 8px 8px 0;
  line-height: 1.8;
}

.ai-report strong {
  display: block;
  margin-top: 10px;
}

.ai-report ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.loading-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(31, 122, 92, 0.18);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.daily-row,
.request-row,
.user-row {
  display: grid;
  grid-template-columns: 1.1fr 0.8fr 1.5fr auto;
  gap: 12px;
  align-items: center;
}

.approval-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.danger-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #dfb4ad;
  border-radius: 8px;
  background: #fff4f2;
  color: var(--red);
  font-weight: 800;
}

.audit-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 12px;
  align-items: center;
}

.role-select {
  min-width: 150px;
}

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

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

.person-card {
  display: grid;
  gap: 14px;
}

.person-card .stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #faf2e5;
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-box strong {
  display: block;
  margin-top: 4px;
}

.question-box,
.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 92, 0.14);
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(29, 45, 41, 0.52);
}

.modal-card {
  width: min(820px, calc(100vw - 28px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin: 4px 0 0;
}

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

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

input[type="range"] {
  accent-color: var(--green);
  min-height: 42px;
}

.stack-form .primary-button.full {
  margin: 0;
}

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

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

@media (max-width: 1100px) {
  .metric {
    grid-column: span 6;
  }

  .span-5,
  .span-6,
  .span-7 {
    grid-column: 1 / -1;
  }

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

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

  .sidebar {
    position: static;
    height: auto;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .ticket-top,
  .row-between {
    flex-direction: column;
    align-items: stretch;
  }

  .metric {
    grid-column: 1 / -1;
  }

  .member-row,
  .daily-row,
  .request-row,
  .approval-card,
  .audit-row,
  .user-row {
    grid-template-columns: 1fr;
  }

  .people-grid,
  .form-grid,
  .form-grid.compact,
  .role-picker,
  .auth-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .metric,
  .panel,
  .ticket-card,
  .login-card {
    animation: liftIn 0.42s ease both;
  }

  @keyframes liftIn {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}
