:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-strong: #eef4f1;
  --line: #d6dfd9;
  --line-strong: #b8c7be;
  --text: #18211d;
  --muted: #60706a;
  --accent: #2f5d50;
  --accent-strong: #24473e;
  --warning: #a85f00;
  --warning-bg: #fff4df;
  --focus: #1f7a64;
  --shadow: 0 8px 26px rgb(30 48 42 / 10%);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.button-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
}

input[type="text"],
input[type="search"],
input[type="number"] {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 8px;
  background: white;
}

input:focus,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.app-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.app-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.side-panel,
.main-panel {
  min-width: 0;
}

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

.panel {
  padding: 14px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.file-picker {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.file-picker input {
  width: 100%;
}

.metrics {
  margin: 0;
  display: grid;
  gap: 8px;
}

.metrics div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}

.metrics div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

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

.metrics dd {
  margin: 0;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
  padding: 8px;
  border-radius: 8px 8px 0 0;
}

.tab {
  border-color: transparent;
  background: transparent;
}

.tab.active {
  background: var(--surface);
  border-color: var(--line-strong);
  font-weight: 700;
}

.tab-panel {
  display: none;
  padding: 12px;
}

.tab-panel.active {
  display: block;
}

.table-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.filter,
.add-customer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.filter input {
  width: min(280px, 45vw);
}

.add-customer input {
  width: min(240px, 40vw);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 190px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
}

.empty-copy {
  color: var(--muted);
  font-size: 14px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1040px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 7px 8px;
  vertical-align: middle;
  background: white;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-strong);
  color: #24302b;
  font-size: 12px;
  text-align: center;
}

td:first-child,
th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: white;
  min-width: 190px;
  max-width: 260px;
}

th:first-child {
  z-index: 4;
  background: var(--surface-strong);
}

.month-cell {
  min-width: 118px;
}

.planned {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.actual-input {
  width: 100%;
  min-width: 96px;
  text-align: right;
}

.missing {
  background: var(--warning-bg);
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--warning);
  background: var(--warning-bg);
}

.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  background: #1f2a25;
  color: white;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .app-header {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    width: 100%;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter,
  .add-customer {
    width: 100%;
  }

  .filter input,
  .add-customer input {
    width: 100%;
  }
}
