:root {
  color-scheme: dark;
  --bg: #06110f;
  --panel: #10211e;
  --panel-strong: #142c27;
  --line: rgba(178, 230, 217, .22);
  --text: #f3fbf8;
  --muted: #a8c9c0;
  --accent: #2dd4bf;
  --accent-2: #f59e0b;
  --good: #86efac;
  --warn: #facc15;
  --bad: #fb7185;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(6, 17, 15, .98), rgba(10, 35, 30, .95) 48%, rgba(5, 14, 13, .99)),
    repeating-linear-gradient(90deg, rgba(45, 212, 191, .1) 0 1px, transparent 1px 86px);
  color: var(--text);
  font-family: "Noto Sans JP", "Segoe UI", "Yu Gothic UI", Meiryo, sans-serif;
}

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

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 42px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.topbar,
.metric-card,
.entry-panel,
.advice-panel,
.chart-panel,
.data-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .055), transparent 32%),
    linear-gradient(160deg, rgba(16, 33, 30, .96), rgba(6, 19, 17, .9));
  box-shadow: 0 20px 56px rgba(0, 0, 0, .24), inset 0 1px 0 rgba(255, 255, 255, .08);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

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

h2 {
  font-size: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  min-height: 118px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

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

.metric-card strong {
  font-size: 30px;
  line-height: 1;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .8fr);
  gap: 14px;
  min-width: 0;
}

.entry-panel,
.advice-panel,
.chart-panel,
.data-panel {
  padding: 16px;
}

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

.primary-btn,
.ghost-btn,
.range-btn,
.delete-btn {
  min-height: 34px;
  border: 1px solid rgba(214, 255, 247, .16);
  border-radius: 999px;
  padding: 6px 15px;
  color: var(--text);
  font-weight: 850;
  cursor: pointer;
}

.primary-btn {
  background: linear-gradient(135deg, #2dd4bf, #0f766e);
  box-shadow: 0 14px 30px rgba(45, 212, 191, .22);
}

.ghost-btn,
.range-btn,
.delete-btn {
  background: rgba(255, 255, 255, .06);
}

.delete-btn {
  min-height: 28px;
  padding: 4px 10px;
  color: #fecdd3;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(178, 230, 217, .24);
  border-radius: 10px;
  background: rgba(2, 10, 9, .72);
  color: var(--text);
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

.memo-field {
  margin-top: 10px;
}

.advice-list {
  display: grid;
  gap: 10px;
}

.advice-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .045);
}

.advice-item strong {
  display: block;
  margin-bottom: 4px;
}

.advice-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.chart-panel canvas {
  width: 100%;
  height: 320px;
  display: block;
  border-radius: 10px;
  background: rgba(2, 10, 9, .52);
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
}

.range-btn {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
}

.range-btn.active {
  background: rgba(45, 212, 191, .24);
  border-color: rgba(45, 212, 191, .5);
}

.import-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.upload-box {
  min-height: 82px;
  place-content: center;
  border: 1px dashed rgba(178, 230, 217, .36);
  border-radius: 12px;
  background: rgba(45, 212, 191, .08);
  text-align: center;
  cursor: pointer;
}

.upload-box input {
  display: none;
}

.sync-note {
  display: grid;
  gap: 6px;
  align-content: center;
  padding: 12px;
  border: 1px solid rgba(245, 158, 11, .28);
  border-radius: 12px;
  background: rgba(245, 158, 11, .08);
}

.sync-note span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(178, 230, 217, .14);
  text-align: left;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.empty-row {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 14, 13, .94);
  color: var(--text);
  box-shadow: 0 18px 46px rgba(0, 0, 0, .32);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

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

@media (max-width: 900px) {
  .summary-grid,
  .workbench,
  .import-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 16px, 1180px);
    padding-top: 10px;
    gap: 9px;
  }

  .topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 96px;
  }

  .chart-panel canvas {
    height: 260px;
  }
}
