:root {
  color-scheme: light;
  --bg: #f4f1eb;
  --surface: #fffdf8;
  --surface-2: #ebe7dc;
  --ink: #1e2428;
  --muted: #6e7477;
  --line: #d9d2c5;
  --accent: #1f7a68;
  --accent-2: #bb4d3d;
  --gold: #c7983b;
  --blue: #356d9b;
  --shadow: 0 18px 50px rgba(42, 36, 27, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(33, 40, 42, 0.7);
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 18px 0 6px;
  font-size: 32px;
}

.login-card p {
  margin-bottom: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.blurred {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

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

button {
  cursor: pointer;
}

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

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

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

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: #f8f3ea;
  color: #21282a;
  font-weight: 800;
  border-radius: 8px;
}

.brand h1,
.brand p,
h2,
h3,
h4,
p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p {
  color: #d3c8b8;
  font-size: 13px;
  margin-top: 4px;
}

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

.nav-item,
.text-button,
.small-button,
.primary-button,
.danger-button,
.icon-button,
.segmented button {
  border: 0;
  border-radius: 8px;
}

.nav-item {
  padding: 13px 14px;
  background: transparent;
  color: #e8dfd0;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.panel-label,
.eyebrow {
  text-transform: uppercase;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sidebar-panel .panel-label {
  color: #d8c8a8;
}

.sidebar-panel p {
  margin-top: 10px;
  line-height: 1.6;
}

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

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

h2 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.05;
  margin-top: 4px;
}

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

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.file-button input {
  display: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  font-size: 34px;
}

.metric.urgent strong {
  color: var(--accent-2);
}

.content-grid,
.settings-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
}

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

.panel {
  padding: 20px;
}

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

h3 {
  font-size: 22px;
  margin-top: 3px;
}

.text-button,
.small-button {
  background: var(--surface-2);
  color: var(--ink);
  padding: 8px 12px;
}

.primary-button {
  background: var(--accent);
  color: white;
  padding: 11px 16px;
  font-weight: 700;
}

.danger-button {
  background: #f1ddd8;
  color: #9f3528;
  padding: 11px 16px;
  font-weight: 800;
}

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

.hidden {
  display: none !important;
}

.item-strip,
.cards-grid {
  display: grid;
  gap: 14px;
}

.item-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cards-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.item-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.item-image {
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(135deg, rgba(31, 122, 104, 0.16), rgba(187, 77, 61, 0.15)),
    #e7e2d7;
  background-position: center;
  background-size: cover;
}

.item-body {
  padding: 14px;
}

.item-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

h4 {
  font-size: 17px;
  line-height: 1.35;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7f0ec;
  color: #176657;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.meta,
.notes,
.spec-list p {
  color: var(--muted);
  line-height: 1.55;
}

.meta {
  margin-top: 8px;
  font-size: 13px;
}

.notes {
  margin-top: 10px;
  min-height: 44px;
}

.item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  gap: 10px;
}

.price {
  color: var(--blue);
  font-weight: 800;
}

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

.timeline-entry {
  padding: 12px;
  border-left: 4px solid var(--gold);
  background: #fbf7ef;
  border-radius: 4px;
}

.timeline-entry strong {
  display: block;
  margin-bottom: 4px;
}

.advisor-note {
  display: grid;
  gap: 16px;
}

.advisor-note p {
  color: var(--muted);
  line-height: 1.7;
}

.library-layout,
.calendar-layout,
.ai-layout {
  display: grid;
  gap: 18px;
}

.library-layout {
  grid-template-columns: 360px minmax(0, 1fr);
}

.calendar-layout,
.ai-layout {
  grid-template-columns: minmax(0, 1fr) 360px;
}

form,
.compact-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-note,
.form-status {
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.form-status {
  min-height: 18px;
  color: var(--accent);
  font-weight: 800;
}

.form-status.error {
  color: var(--accent-2);
}

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

textarea {
  resize: vertical;
}

.inline-fields,
.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.filter-row {
  grid-template-columns: minmax(180px, 1fr) 190px 170px;
  margin-bottom: 14px;
}

.calendar-panel {
  overflow: hidden;
}

.calendar-controls {
  display: flex;
  gap: 8px;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekday-row {
  margin-bottom: 8px;
}

.weekday-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  min-height: 104px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  display: grid;
  align-content: start;
  gap: 6px;
}

.calendar-day.muted {
  opacity: 0.42;
}

.calendar-day.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.calendar-day.today .day-number {
  background: var(--accent-2);
  color: white;
}

.day-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-weight: 800;
}

.event-count {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  min-height: 16px;
}

.day-events {
  display: grid;
  gap: 4px;
}

.event-chip {
  display: block;
  padding: 5px 7px;
  border-radius: 6px;
  background: #e8f0f4;
  color: #225577;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-timeline {
  margin-top: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 14px;
}

.segmented button {
  padding: 10px;
  background: transparent;
}

.segmented button.active {
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.provider-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.provider-list label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.provider-list input {
  width: auto;
}

.chat-panel {
  min-height: 640px;
  display: flex;
  flex-direction: column;
}

.chat-output {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8f1;
}

.message {
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.message strong {
  display: block;
  margin-bottom: 6px;
}

.chat-form {
  margin-top: 12px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty {
  color: var(--muted);
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

.detail-dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 22px;
}

.detail-dialog::backdrop {
  background: rgba(30, 36, 40, 0.48);
}

.detail-head,
.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) 120px 1.1fr;
  gap: 18px;
  margin-top: 18px;
}

.detail-image,
.part-image {
  background:
    linear-gradient(135deg, rgba(31, 122, 104, 0.16), rgba(187, 77, 61, 0.15)),
    #e7e2d7;
  background-position: center;
  background-size: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-image {
  min-height: 330px;
}

.detail-gallery {
  display: grid;
  align-content: start;
  gap: 10px;
}

.gallery-thumb {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--line);
  border-radius: 8px;
  background-color: #e7e2d7;
  background-position: center;
  background-size: cover;
}

.gallery-thumb.active {
  border-color: var(--accent);
}

.detail-info,
.detail-section {
  display: grid;
  gap: 18px;
}

.detail-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.detail-list div {
  padding: 12px;
  background: #fbf7ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-list dd {
  margin: 5px 0 0;
  font-weight: 700;
}

.detail-notes {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}

.detail-section {
  margin-top: 22px;
}

.parts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.part-card {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.part-image {
  width: 78px;
  aspect-ratio: 1;
}

.part-card p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.part-card span {
  display: block;
  margin-top: 7px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.part-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(180px, 1.4fr) 150px 120px minmax(160px, 1.1fr);
  gap: 10px;
  align-items: start;
  margin-bottom: 14px;
}

.photo-upload-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.part-form .form-actions {
  grid-column: 1 / -1;
}

.part-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.mini-danger {
  border: 0;
  border-radius: 8px;
  background: #f1ddd8;
  color: #9f3528;
  padding: 8px 10px;
  font-weight: 800;
}

.detail-actions {
  margin-top: 20px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .app-shell,
  .library-layout,
  .calendar-layout,
  .ai-layout,
  .content-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 720px) {
  main,
  .sidebar {
    padding: 18px;
  }

  .metrics-grid,
  .item-strip,
  .filter-row,
  .inline-fields {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    align-items: flex-start;
  }

  .calendar-panel {
    overflow-x: auto;
  }

  .weekday-row,
  .calendar-grid {
    min-width: 760px;
  }

  .detail-layout,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .detail-gallery {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .part-form {
    grid-template-columns: 1fr;
  }

  .photo-upload-form {
    grid-template-columns: 1fr;
  }
}
