:root {
  color-scheme: light;
  --forest: #172a28;
  --forest-2: #23403b;
  --cream: #f4f0e7;
  --paper: #fbfaf6;
  --white: #fff;
  --ink: #202b2a;
  --muted: #6b7673;
  --line: #d7ddd8;
  --sage: #bcd1b9;
  --amber: #efa83d;
  --amber-soft: #fff1d7;
  --blue: #4a7291;
  --red: #aa3f46;
  --red-soft: #f6dfe0;
  --sans: "Yu Gothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.7;
}

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

button,
select {
  cursor: pointer;
}

button,
input,
select,
textarea {
  border-radius: 0;
}

:focus-visible {
  outline: 3px solid #11768a;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-underline-offset: 0.25em;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 16px;
  transform: translateY(-150%);
  background: #fff;
  color: #000;
}

.skip-link:focus {
  transform: none;
}

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

.sidebar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  height: 100vh;
  padding: 26px 20px;
  flex-direction: column;
  background: var(--forest);
  color: #fff;
}

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

.brand__mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: var(--amber);
  color: var(--forest);
  font-family: var(--serif);
  font-size: 1.25rem;
}

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

.brand strong {
  font-size: 1.06rem;
  letter-spacing: 0.06em;
}

.brand small {
  color: rgb(255 255 255 / 55%);
  font-size: 0.62rem;
}

.nav-toggle {
  display: none;
}

.main-nav {
  display: grid;
  margin-top: 36px;
  gap: 2px;
}

.main-nav a {
  display: grid;
  min-height: 48px;
  padding: 10px 12px;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 8px;
  color: rgb(255 255 255 / 72%);
  font-size: 0.82rem;
  text-decoration: none;
}

.main-nav a span {
  color: rgb(255 255 255 / 38%);
  font-family: var(--serif);
  font-size: 0.72rem;
}

.main-nav a:is(:hover, [aria-current="page"]) {
  background: var(--forest-2);
  color: #fff;
}

.main-nav a[aria-current="page"] {
  border-left: 3px solid var(--amber);
}

.sidebar__foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgb(255 255 255 / 20%);
  color: rgb(255 255 255 / 60%);
  font-size: 0.7rem;
}

.sidebar__foot p {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sidebar__foot a {
  color: #fff;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage);
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 76px;
  padding: 12px clamp(22px, 4vw, 54px);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgb(251 250 246 / 94%);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.topbar strong {
  display: block;
  margin-top: 2px;
}

.topbar__actions,
.heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar button,
.heading-actions button,
.primary-action,
.panel button,
.data-card button,
.file-button {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--forest);
  background: #fff;
  color: var(--forest);
}

.button--accent,
.primary-action {
  background: var(--forest) !important;
  color: #fff !important;
}

.demo-badge {
  padding: 5px 9px;
  background: var(--amber-soft);
  color: #77500e;
  font-size: 0.68rem;
}

main {
  width: min(100%, 1500px);
  margin-inline: auto;
  padding: clamp(30px, 5vw, 68px);
}

.view {
  min-height: calc(100vh - 180px);
}

.page-heading {
  display: flex;
  margin-bottom: 34px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-heading h1 {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 500;
  letter-spacing: 0.05em;
}

.page-heading p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
}

.text-link {
  color: var(--forest);
  font-weight: 700;
}

.metric-grid {
  display: grid;
  margin-bottom: 24px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--forest);
  border-left: 1px solid var(--forest);
}

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

.metric-card {
  min-height: 152px;
  padding: 22px;
  border-right: 1px solid var(--forest);
  border-bottom: 1px solid var(--forest);
  background: var(--paper);
}

.metric-card span,
.metric-card strong,
.metric-card small {
  display: block;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.76rem;
}

.metric-card strong {
  margin-top: 16px;
  font-family: var(--serif);
  font-size: clamp(1.9rem, 3.5vw, 3rem);
  font-weight: 500;
  line-height: 1;
}

.metric-card small {
  margin-top: 12px;
  color: var(--muted);
}

.metric-card--alert strong {
  color: var(--red);
}

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

.panel {
  min-width: 0;
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--line);
  background: var(--paper);
}

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

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

.panel-heading h2,
.data-card h2,
.privacy-panel h2 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 500;
}

.panel-heading a {
  color: var(--muted);
  font-size: 0.76rem;
}

.project-list {
  display: grid;
  gap: 12px;
}

.project-row {
  display: grid;
  padding: 16px 0;
  grid-template-columns: minmax(13em, 1fr) minmax(8em, 0.65fr) minmax(10em, 1fr) 7em;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.project-row h3 {
  margin: 0;
  font-size: 0.95rem;
}

.project-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.project-row progress,
.bar-row progress,
.project-card progress {
  width: 100%;
  height: 9px;
  border: 0;
  background: #dfe5df;
}

progress::-webkit-progress-bar {
  background: #dfe5df;
}

progress::-webkit-progress-value {
  background: var(--forest);
}

progress::-moz-progress-bar {
  background: var(--forest);
}

.status-pill,
.priority-pill {
  display: inline-flex;
  width: fit-content;
  padding: 4px 8px;
  background: #e8ece8;
  color: var(--forest);
  font-size: 0.67rem;
  font-weight: 700;
}

.status-pill--planning {
  background: var(--amber-soft);
  color: #77500e;
}

.status-pill--review {
  background: #dfe9f2;
  color: #315b7c;
}

.status-pill--done {
  background: var(--sage);
}

.deadline-list,
.simple-list,
.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.deadline-list li,
.simple-list li {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.deadline-list time {
  display: block;
  color: var(--red);
  font-family: var(--serif);
  font-size: 0.75rem;
}

.deadline-list strong,
.deadline-list span,
.simple-list strong,
.simple-list span {
  display: block;
}

.deadline-list span,
.simple-list span {
  color: var(--muted);
  font-size: 0.72rem;
}

.cash-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.cash-summary div {
  padding: 16px;
  border: 1px solid var(--line);
}

.cash-summary span,
.cash-summary strong {
  display: block;
}

.cash-summary span {
  color: var(--muted);
  font-size: 0.72rem;
}

.cash-summary strong {
  margin-top: 7px;
  font-family: var(--serif);
  font-size: 1.25rem;
}

.table-tools {
  display: flex;
  margin-bottom: 22px;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.table-tools label {
  width: min(100%, 420px);
  color: var(--muted);
  font-size: 0.72rem;
}

.table-tools input {
  width: 100%;
  min-height: 46px;
  margin-top: 5px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #fff;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

td {
  font-size: 0.82rem;
}

td small {
  display: block;
  color: var(--muted);
}

.table-action {
  min-width: 42px !important;
  min-height: 42px !important;
  padding: 6px !important;
  border-color: var(--line) !important;
  color: var(--red) !important;
}

.filter-row {
  display: flex;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 7px;
}

.filter-row button {
  min-height: 42px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  background: #fff;
}

.filter-row button[aria-pressed="true"] {
  border-color: var(--forest);
  background: var(--forest);
  color: #fff;
}

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

.project-card {
  padding: 24px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.project-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.project-card h2 {
  margin: 20px 0 0;
  font-family: var(--serif);
  font-size: 1.28rem;
  font-weight: 500;
}

.project-card p {
  color: var(--muted);
  font-size: 0.76rem;
}

.project-card dl {
  margin: 20px 0;
}

.project-card dl div {
  display: flex;
  padding: 8px 0;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.project-card dt {
  color: var(--muted);
  font-size: 0.72rem;
}

.project-card dd {
  margin: 0;
  font-size: 0.78rem;
  text-align: right;
}

.estimate-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
}

.estimate-index h2 {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
}

.estimate-index button {
  width: 100%;
  min-height: 62px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}

.estimate-index button[aria-pressed="true"] {
  background: var(--forest);
  color: #fff;
}

.estimate-index strong,
.estimate-index small {
  display: block;
}

.estimate-index small {
  color: var(--muted);
}

.estimate-index button[aria-pressed="true"] small {
  color: rgb(255 255 255 / 65%);
}

.estimate-editor {
  min-height: 600px;
}

.empty-placeholder {
  display: grid;
  min-height: 500px;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.estimate-header {
  display: flex;
  margin-bottom: 28px;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
}

.estimate-header > div {
  display: grid;
  min-width: min(100%, 520px);
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.estimate-header label,
.settings-form label,
.form-dialog label {
  color: var(--muted);
  font-size: 0.72rem;
}

.estimate-header input,
.estimate-header select,
.estimate-table input,
.settings-form input,
.settings-form select,
.form-dialog input,
.form-dialog select,
.form-dialog textarea {
  width: 100%;
  min-height: 44px;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.estimate-header dl {
  min-width: 180px;
  margin: 0;
}

.estimate-header dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.estimate-header dt,
.estimate-header dd {
  font-size: 0.72rem;
}

.estimate-header dt {
  color: var(--muted);
}

.estimate-header dd {
  margin: 0;
}

.estimate-table {
  min-width: 680px;
}

.estimate-table input[type="number"] {
  text-align: right;
}

.add-row-button {
  margin-top: 14px;
}

.estimate-totals {
  display: flex;
  margin-top: 30px;
  align-items: end;
  justify-content: flex-end;
  gap: 30px;
}

.estimate-totals dl {
  width: min(100%, 360px);
  margin: 0;
}

.estimate-totals dl div {
  display: flex;
  padding: 9px 0;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.estimate-totals dd {
  margin: 0;
}

.estimate-total {
  color: var(--forest);
  font-size: 1.2rem;
  font-weight: 800;
}

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

.kanban-column {
  min-height: 520px;
  padding: 18px;
  border-top: 4px solid var(--forest);
  background: rgb(255 255 255 / 50%);
}

.kanban-column h2 {
  display: flex;
  margin: 0 0 18px;
  align-items: center;
  justify-content: space-between;
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 500;
}

.kanban-column h2 span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  background: var(--forest);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.7rem;
}

.task-card {
  margin-bottom: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.task-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-card h3 {
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.task-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.task-card__actions {
  display: flex;
  margin-top: 15px;
  gap: 6px;
}

.task-card__actions button {
  min-width: 42px;
  min-height: 40px;
  padding: 5px 8px;
  border-color: var(--line);
}

.priority-pill--high {
  background: var(--red-soft);
  color: var(--red);
}

.priority-pill--medium {
  background: var(--amber-soft);
  color: #77500e;
}

.calendar-summary {
  display: grid;
  margin-bottom: 28px;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--forest);
}

.calendar-day {
  min-height: 112px;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.calendar-day:last-child {
  border-right: 0;
}

.calendar-day strong,
.calendar-day span {
  display: block;
}

.calendar-day strong {
  font-family: var(--serif);
  font-size: 1.25rem;
}

.calendar-day span {
  color: var(--muted);
  font-size: 0.67rem;
}

.calendar-day em {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 6px;
  background: var(--amber-soft);
  color: #77500e;
  font-size: 0.64rem;
  font-style: normal;
}

.timeline {
  border-top: 1px solid var(--forest);
}

.timeline li {
  display: grid;
  min-height: 90px;
  padding: 18px 0;
  grid-template-columns: 130px 120px 1fr;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.timeline time {
  font-family: var(--serif);
  font-size: 1.05rem;
}

.timeline p {
  margin: 0;
}

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

.finance-row,
.bar-row {
  display: grid;
  padding: 13px 0;
  grid-template-columns: minmax(10em, 1fr) 2fr 8em;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.finance-row strong,
.finance-row small {
  display: block;
}

.finance-row small,
.bar-row span {
  color: var(--muted);
  font-size: 0.7rem;
}

.bar-row output {
  text-align: right;
}

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

.data-card {
  position: relative;
  min-height: 260px;
  padding-right: 70px;
}

.data-card__no {
  position: absolute;
  top: 24px;
  right: 24px;
  color: var(--sage);
  font-family: var(--serif);
  font-size: 2rem;
}

.data-card p {
  color: var(--muted);
  font-size: 0.8rem;
}

.data-card > button,
.data-card > div,
.file-button {
  display: inline-flex;
  margin-top: 26px;
  align-items: center;
  gap: 8px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.data-card--danger {
  border-color: #d7a8aa;
}

.danger-action {
  border-color: var(--red) !important;
  background: var(--red) !important;
  color: #fff !important;
}

.privacy-panel {
  margin-top: 22px;
  padding: 24px 30px;
  border-left: 4px solid var(--forest);
  background: var(--sage);
}

.privacy-panel p {
  margin-bottom: 0;
  color: #374c3a;
}

.settings-form {
  max-width: 760px;
}

.settings-form form {
  display: grid;
  gap: 22px;
}

.settings-form small {
  display: block;
  margin-top: 5px;
}

.form-dialog,
.confirm-dialog {
  width: min(100% - 36px, 620px);
  max-height: min(88vh, 800px);
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--forest);
  background: var(--paper);
}

.form-dialog::backdrop,
.confirm-dialog::backdrop {
  background: rgb(23 42 40 / 62%);
}

.form-dialog form,
.confirm-dialog form {
  display: grid;
  padding: 28px;
  gap: 18px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.dialog-heading h2,
.confirm-dialog h2 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 500;
}

.dialog-heading button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: #fff;
}

.form-dialog textarea {
  min-height: 110px;
  resize: vertical;
}

.dialog-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.dialog-actions,
.confirm-dialog form > div {
  display: flex;
  margin-top: 10px;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-actions button,
.confirm-dialog button {
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  background: #fff;
}

.toast {
  position: fixed;
  z-index: 70;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100% - 48px));
  padding: 14px 18px;
  background: var(--forest);
  color: #fff;
  box-shadow: 0 14px 36px rgb(23 42 40 / 28%);
}

.empty {
  padding: 30px 0;
  color: var(--muted);
  text-align: center;
}

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

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

  .estimate-index > div {
    display: flex;
    overflow-x: auto;
  }

  .estimate-index button {
    min-width: 220px;
  }
}

@media (max-width: 1180px) {
  .project-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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

  .sidebar__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .nav-toggle {
    display: block;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid rgb(255 255 255 / 35%);
    background: transparent;
    color: #fff;
  }

  .main-nav {
    display: none;
    margin-top: 14px;
    grid-template-columns: repeat(2, 1fr);
  }

  .main-nav[data-open="true"] {
    display: grid;
  }

  .sidebar__foot {
    display: none;
  }

  .topbar {
    top: 70px;
  }

  .topbar__actions button:not(.button--accent),
  .demo-badge {
    display: none;
  }

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

  .kanban-column {
    min-height: 220px;
  }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 68px;
    padding-inline: 16px;
  }

  main {
    padding: 30px 16px 60px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading .primary-action,
  .heading-actions {
    width: 100%;
  }

  .heading-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-grid,
  .report-grid,
  .data-grid,
  .project-card-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .metric-grid--three {
    grid-template-columns: 1fr 1fr;
  }

  .project-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .calendar-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .calendar-day {
    border-bottom: 1px solid var(--line);
  }

  .timeline li {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .estimate-header,
  .estimate-totals {
    align-items: stretch;
    flex-direction: column;
  }

  .estimate-header > div,
  .dialog-columns {
    grid-template-columns: 1fr;
  }

  .finance-row,
  .bar-row {
    grid-template-columns: 1fr;
  }

  .bar-row output {
    text-align: left;
  }

  .data-card {
    padding-right: 24px;
  }

  .data-card__no {
    position: static;
  }
}

@media print {
  .sidebar,
  .topbar,
  .page-heading,
  .estimate-index,
  .estimate-totals button {
    display: none !important;
  }

  .app-layout,
  .estimate-layout {
    display: block;
  }

  main {
    padding: 0;
  }

  .view:not([data-view="estimates"]) {
    display: none !important;
  }

  .estimate-editor {
    border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
