:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --line: #d8deea;
  --text: #172033;
  --muted: #66728a;
  --accent: #4f46e5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.wrap {
  max-width: 1460px;
  margin: 0 auto;
  padding: 24px;
}

h1 {
  margin: 0 0 6px;
  font-size: 42px;
  line-height: 1.1;
}

.sub {
  color: var(--muted);
  margin-bottom: 22px;
  font-size: 15px;
}

.layout {
  display: grid;
  grid-template-columns: 30% 70%;
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
}

.panel-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 12px;
}

.section-head .panel-title {
  white-space: nowrap;
}

.left,
.section {
  padding: 18px;
}

.row-3,
.row-2 {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.row-3 {
  grid-template-columns: repeat(3, 1fr);
}

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

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd6e4;
  border-radius: 14px;
  background: white;
  color: var(--text);
  padding: 10px 12px;
}

button {
  border: 1px solid #cfd6e4;
  background: white;
  color: var(--text);
  border-radius: 14px;
  padding: 11px 16px;
  font-weight: 800;
  cursor: pointer;
}

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

.grid-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: auto;
  background: white;
  max-height: 320px;
}

.input-grid {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.input-grid th,
.input-grid td {
  border-bottom: 1px solid #edf1f7;
  border-right: 1px solid #edf1f7;
  padding: 0;
  height: 40px;
}

.input-grid th:last-child,
.input-grid td:last-child {
  border-right: 0;
}

.input-grid thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  padding: 10px 10px;
}

.input-grid td input {
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 10px;
  outline: none;
  background: transparent;
}

.input-grid td input:focus {
  background: #eef2ff;
}

.delete-btn {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #fff7f7;
  color: #b42318;
  font-weight: 700;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

details {
  margin-top: 12px;
  margin-bottom: 12px;
}

summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

textarea {
  min-height: 180px;
  margin-top: 10px;
  resize: vertical;
  line-height: 1.45;
}

.hint {
  margin-top: 12px;
  background: #eef2ff;
  color: #3730a3;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.6;
}

.right {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.stat {
  padding: 16px;
}

.stat .k {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 10px;
}

.stat .v {
  font-size: 28px;
  font-weight: 900;
}

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

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

.sheet-area {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 14px;
}

.sheet-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 12px 58px;
  background: white;
  width: 100%;
  min-width: 0;
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

.sheet-title {
  font-weight: 900;
}

canvas {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafa;
}

.sheet-canvas-btn {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 12px;
  cursor: zoom-in;
}

.sheet-canvas-btn:focus-visible {
  outline: 3px solid rgba(79, 70, 229, 0.35);
  outline-offset: 3px;
}

.sheet-canvas-btn canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.sheet-actions {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  justify-content: flex-end;
}

.sheet-download-btn {
  min-width: 96px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border-color: #4f46e5;
  color: #fff;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.22);
}

.sheet-download-btn:hover {
  filter: brightness(0.95);
}

.summary-download-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 720px) {
  .summary-download-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .summary-download-actions .sheet-download-btn {
    min-width: 0;
  }
}

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

.table th,
.table td {
  border-bottom: 1px solid #edf1f7;
  padding: 10px 6px;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.7);
  z-index: 1000;
}

.modal.is-open {
  display: flex;
}

.modal-dialog {
  position: relative;
  width: min(96vw, 1400px);
  max-height: 92vh;
  background: #ffffff;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0 56px 12px 0;
}

.modal-canvas-wrap {
  overflow: auto;
  max-height: calc(92vh - 90px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafa;
}

.modal-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fafafa;
}

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

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

@media (max-width: 720px) {
  .row-3,
  .row-2,
  .stats {
    grid-template-columns: 1fr;
  }

  .sheet-area {
    grid-template-columns: 1fr;
  }

  .sheet-card {
    width: 100%;
    min-width: 0;
  }

  .sheet-canvas-btn,
  .sheet-canvas-btn canvas,
  canvas {
    width: 100%;
    max-width: 100%;
  }
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 30%) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.left-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.ad-banner {
  text-align: center;
}

.ad-banner a,
.ad-banner img {
  display: inline-block;
}

.pc-only-banner {
  display: block;
}

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

.ad-banner-wide {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 8px 0;
  overflow: hidden;
}

.ad-banner-wide .adsbygoogle {
  max-width: 100%;
}

.ad-banner-wide iframe,
.ad-banner-wide img,
.ad-banner-wide ins {
  max-width: 100%;
}

@media (max-width: 970px) {
  .ad-banner-wide {
    justify-content: center;
  }
}

.site-footer {
  margin-top: 40px;
  padding: 24px 16px 32px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
}

.site-footer-inner {
  max-width: 1460px;
  margin: 0 auto;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.8;
  color: #6b7280;
}

.footer-links {
  margin-top: 8px;
}

.footer-links a,
.text-link {
  color: #4f46e5;
  text-decoration: none;
  font-weight: 700;
}

.footer-links a:hover,
.text-link:hover {
  text-decoration: underline;
}

.terms-wrap {
  max-width: 980px;
}

.terms-card h2 {
  margin: 28px 0 10px;
  font-size: 20px;
}

.terms-card p {
  margin: 0 0 14px;
  line-height: 1.9;
  color: #334155;
}

.terms-actions {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}