:root {
  --bg: #f2f7ff;
  --panel: #ffffff;
  --panel-strong: #eef5ff;
  --ink: #172033;
  --muted: #66758f;
  --line: #dbe7f7;
  --brand: #2868f0;
  --brand-dark: #174fce;
  --accent: #2f80ed;
  --warn: #d96c2c;
  --shadow: 0 10px 24px rgba(35, 72, 125, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.app-shell.nav-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px 12px;
  background: #f7fbff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 20;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.brand-logo {
  width: 136px;
  height: auto;
  object-fit: contain;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--brand);
}

.nav-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #24405f;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  text-align: left;
}

.nav-item:hover,
.nav-item:focus-visible {
  background: #e8f2ff;
  outline: none;
}

.nav-item.active-nav {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(40, 104, 240, 0.2);
}

.nav-item img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: brightness(0);
  flex: 0 0 auto;
}

.nav-item.active-nav img {
  filter: brightness(0) invert(1);
}

.primary-nav {
  background: #e6f0ff;
  color: var(--brand-dark);
  font-weight: 700;
}

.nav-settings {
  margin-top: auto;
}

.account-card {
  margin-top: 0;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.account-card strong {
  color: var(--ink);
  font-size: 14px;
}

.app-footer {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.app-footer strong {
  color: var(--brand-dark);
  font-size: 12px;
}

.nav-collapsed .brand-logo,
.nav-collapsed .nav-item span,
.nav-collapsed .account-card,
.nav-collapsed .app-footer {
  display: none;
}

.nav-collapsed .sidebar-head {
  justify-content: center;
}

.nav-collapsed .nav-item {
  justify-content: center;
  padding: 0;
}

.main {
  min-width: 0;
  padding: 22px clamp(16px, 3vw, 34px) 56px;
}

.topbar {
  width: min(1120px, 100%);
  margin: 0 auto 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.topbar h1,
.hero-strip h2,
.section-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(22px, 3vw, 30px);
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff6e9;
  color: #8b4b12;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.connected {
  background: #eaf8ef;
  color: #157242;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.workspace-shell,
.editor-shell,
.settings-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 760px) minmax(280px, 340px);
  gap: 18px;
  align-items: start;
}

.workspace-main {
  display: grid;
  gap: 14px;
}

.editor-main {
  display: grid;
  gap: 14px;
}

.single-view-shell {
  width: min(860px, 100%);
  margin: 0 auto;
}

.hero-strip,
.section-block,
.rail-block,
.report-builder-panel,
.settings-panel {
  background: var(--panel);
  border: 1px solid rgba(219, 231, 247, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-strip {
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.hero-strip p:not(.eyebrow) {
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.7;
}

.hero-actions {
  display: grid;
  gap: 10px;
  min-width: 160px;
}

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

.home-action {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
}

.home-action:hover,
.home-action:focus-visible {
  background: #f8fbff;
  border-color: #bdd4fb;
  outline: none;
}

.home-action img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: brightness(0);
  flex: 0 0 auto;
}

.home-action span {
  display: grid;
  gap: 3px;
}

.home-action small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.metric-item {
  background: var(--panel);
  min-height: 86px;
  padding: 14px;
  display: grid;
  gap: 3px;
}

.metric-item span,
.metric-item small {
  color: var(--muted);
  font-size: 12px;
}

.metric-item strong {
  font-size: 26px;
  color: var(--brand-dark);
}

.section-block,
.report-builder-panel,
.settings-panel {
  padding: 20px;
}

.settings-shell {
  grid-template-columns: minmax(0, 760px) minmax(280px, 340px);
}

.settings-main {
  display: grid;
  gap: 14px;
}

.settings-rail {
  display: grid;
  gap: 14px;
}

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

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

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px);
  gap: 14px;
  padding: 12px 0 16px;
  border-top: 1px solid var(--line);
}

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

.inline-form.compact {
  margin-top: 14px;
}

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

.inline-form label small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}

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

input,
select,
textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 8px;
  border-radius: 4px 4px 0 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(40, 104, 240, 0.16);
  border-bottom-color: var(--brand);
}

.type-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  min-height: 38px;
  border-radius: 999px;
  padding: 0 14px;
  color: var(--muted);
}

.chip.active {
  border-color: var(--brand);
  background: #e8f2ff;
  color: var(--brand-dark);
  font-weight: 700;
}

.upload-drop {
  min-height: 132px;
  border: 1px dashed #a8c4ef;
  border-radius: 8px;
  background: #f8fbff;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--brand);
  background-size: cover;
  background-position: center;
}

.upload-drop input {
  display: none;
}

.upload-drop small {
  color: var(--muted);
  font-weight: 500;
}

.upload-drop.has-preview {
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.primary-button,
.secondary-button,
.ghost-button,
.text-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  background: var(--brand);
  color: #fff;
}

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

.secondary-button {
  background: #e8f2ff;
  border-color: #c9ddff;
  color: var(--brand-dark);
}

.ghost-button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--brand-dark);
}

.text-button {
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--brand);
}

.line-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.data-row {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.row-main,
.mini-row {
  min-width: 0;
  display: grid;
  gap: 3px;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}

.row-main span,
.mini-row span,
.todo-item small,
.empty-note {
  color: var(--muted);
  font-size: 13px;
}

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

.workspace-rail {
  display: grid;
  gap: 14px;
}

.rail-block {
  padding: 18px;
}

.preview-block {
  position: sticky;
  top: 18px;
}

.report-preview-sheet {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  display: grid;
  gap: 12px;
  color: var(--ink);
}

.excel-preview {
  background: #fbfdff;
}

.preview-head {
  border-bottom: 2px solid var(--brand);
  padding-bottom: 10px;
}

.preview-head p {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.preview-head h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.preview-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.preview-meta div {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 8px;
  border-bottom: 1px solid #edf3fb;
  padding-bottom: 6px;
}

.preview-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.preview-meta dd {
  margin: 0;
  min-width: 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}

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

.preview-photo-grid div {
  min-height: 76px;
  border: 1px dashed #bdd4fb;
  border-radius: 6px;
  background: #f8fbff;
  padding: 8px;
  display: grid;
  align-content: end;
  gap: 3px;
}

.preview-photo-grid span {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
}

.preview-photo-grid small,
.preview-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.preview-note {
  margin: 0;
  background: #f8fbff;
  border-radius: 6px;
  padding: 10px;
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 12px;
}

.excel-table th,
.excel-table td {
  border: 1px solid #cfdcf0;
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.excel-table th {
  background: #e8f2ff;
  color: var(--brand-dark);
  font-weight: 700;
  width: 76px;
}

.excel-table thead th {
  background: var(--brand);
  color: #fff;
}

.photo-table th,
.photo-table td {
  font-size: 11px;
}

.todo-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.todo-item > span {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--brand);
}

.mini-row {
  width: 100%;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

.back-button {
  margin-bottom: 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 36px));
  background: #172033;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .workspace-shell,
  .editor-shell,
  .settings-shell {
    grid-template-columns: 1fr;
  }

  .workspace-rail {
    grid-row: auto;
  }
}

@media (max-width: 760px) {
  .app-shell,
  .app-shell.nav-collapsed {
    display: block;
    padding-bottom: 76px;
  }

  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    height: 68px;
    padding: 8px 10px;
    border-right: 0;
    border-top: 1px solid var(--line);
    background: rgba(247, 251, 255, 0.98);
    flex-direction: row;
    align-items: center;
  }

  .sidebar-head {
    display: none;
  }

  .nav-list {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
  }

  .nav-item,
  .primary-nav,
  .nav-settings {
    min-height: 52px;
    justify-content: center;
    padding: 0;
    margin: 0;
  }

  .nav-item span,
  .account-card,
  .app-footer {
    display: none;
  }

  .nav-item img {
    width: 24px;
    height: 24px;
  }

  .main {
    padding: 16px 12px 28px;
  }

  .topbar {
    align-items: flex-start;
    margin-bottom: 14px;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .hero-strip {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .hero-actions {
    min-width: 0;
  }

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

  .home-action-grid {
    grid-template-columns: 1fr;
  }

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

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

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    min-height: 48px;
  }
}

@media (max-width: 480px) {
  .topbar {
    display: grid;
  }

  .section-block,
  .report-builder-panel,
  .settings-panel,
  .rail-block {
    padding: 16px;
  }

  .data-row {
    align-items: flex-start;
    display: grid;
  }
}
