@import url("https://fonts.googleapis.com/css2?family=Klee+One:wght@400;600&display=swap");

:root {
  --bg: #eef5ff;
  --panel: #fff;
  --text: #082957;
  --muted: #526b8f;
  --line: #c6d9ef;
  --line-strong: #a9c3e4;
  --primary: #0b62c3;
  --primary-dark: #0b4aa2;
  --navy: #061f4a;
  --soft-blue: #e6f1ff;
  --gradient-page: linear-gradient(180deg, #eaf3ff 0%, #f7fbff 55%, #eef5ff 100%);
  --gradient-brand: linear-gradient(120deg, #061f4a 0%, #0b4aa2 58%, #0b6edb 100%);
  --gradient-primary: linear-gradient(135deg, #0a55ae 0%, #0b6edb 100%);
  --gradient-soft: linear-gradient(135deg, #edf6ff 0%, #dcecff 100%);
  --danger: #a52929;
  --shadow: 0 12px 35px rgba(12, 63, 132, 0.12);
  --shadow-soft: 0 9px 28px rgba(12, 63, 132, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: light;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--gradient-page);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
.panel,
.record,
.tab {
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.app {
  width: min(calc(100% - 28px), 760px);
  margin: 22px auto;
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--bg);
  box-shadow: 0 18px 50px rgba(12, 63, 132, 0.14);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 110px;
  padding: 24px clamp(18px, 5vw, 34px);
  color: #fff;
  background: var(--gradient-brand);
}

.top h1 {
  margin: 0;
  font-family: "Klee One", "Yuji Syuku", "Hiragino Mincho ProN", serif;
  font-size: clamp(27px, 6vw, 38px);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.25;
  white-space: nowrap;
}

.top-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.orca-mark {
  display: grid;
  flex: 0 0 auto;
  padding: 3px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 18px rgba(3, 19, 47, 0.24), 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.orca-mark img {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: contain;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.app-content {
  padding: 18px clamp(12px, 4vw, 30px) 34px;
}

.pill {
  display: grid;
  flex: 0 0 auto;
  min-width: 60px;
  min-height: 60px;
  padding: 8px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.status-bar,
.update-banner,
.message.notice.show {
  margin: 0 0 14px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--gradient-soft);
  color: var(--primary-dark);
}

.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

#updateBtn:disabled {
  border-color: #8aaed6;
  background: #eef4fb;
  color: #526b8f;
  box-shadow: none;
  cursor: progress;
  opacity: 1;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 4;
  margin: 0 0 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.tab {
  min-width: 0;
  min-height: 76px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.tab:hover {
  border-color: var(--line-strong);
  background: #f3f8ff;
}

.tab.active {
  border-color: var(--primary);
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 6px 15px rgba(11, 98, 195, 0.24);
}

.screen {
  display: none;
  animation: screen-fade 0.18s ease-out;
}

.screen.active {
  display: block;
}

@keyframes screen-fade {
  from { opacity: 0.45; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ad-slot {
  display: grid;
  min-height: 96px;
  margin: 0 0 16px;
  padding: 18px;
  place-content: center;
  border: 1px dashed #b8c9e1;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.ad-label {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.panel,
.record {
  margin: 0 0 16px;
  padding: clamp(18px, 4vw, 28px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.draft-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-soft);
}

.draft-box strong,
.draft-box .sub {
  display: block;
}

.draft-box .sub {
  margin: 3px 0 0;
}

.panel h2,
.dialog-content h2 {
  position: relative;
  width: fit-content;
  margin: 0 0 18px;
  padding: 0 5px 7px;
  color: var(--text);
  font-family: "Klee One", "Yuji Syuku", "Hiragino Mincho ProN", serif;
  font-size: clamp(22px, 5vw, 29px);
  font-weight: 600;
  line-height: 1.35;
}

.panel h2::after,
.dialog-content h2::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 99px;
  background: var(--gradient-primary);
  transform: rotate(-0.8deg);
}

.panel label,
.file-label {
  display: block;
  margin: 15px 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 52px;
  margin-top: 6px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: #0b6edb;
  box-shadow: 0 0 0 3px rgba(11, 110, 219, 0.24);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.link-button:focus-visible {
  outline: 3px solid #78b7ff;
  outline-offset: 2px;
}

input::placeholder {
  color: #7a8799;
}

input[type="file"] {
  min-height: 58px;
  padding: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input[type="file"]::file-selector-button {
  min-height: 42px;
  margin-right: 10px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--primary-dark);
  font-weight: 800;
  cursor: pointer;
}

.sub,
.field-note,
.install-help p,
.privacy-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.field-note {
  display: block;
  margin-top: 5px;
  font-weight: 400;
}

.preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--gradient-soft);
  color: var(--primary-dark);
}

.preview strong {
  white-space: nowrap;
  font-size: 19px;
}

.button-row,
.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--primary-dark);
  font-weight: 800;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--line-strong);
  background: #f3f8ff;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  border-color: var(--primary);
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 6px 15px rgba(11, 98, 195, 0.24);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #094b9a 0%, #095fbe 100%);
}

.btn.small {
  min-height: 44px;
}

.grow {
  flex: 1 1 190px;
}

.danger {
  border-color: #efc8c8;
  background: #fff5f5;
  color: var(--danger);
}

.message {
  display: none;
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 650;
}

.message.show {
  display: block;
}

.message.ok {
  border-color: #a9dec0;
  background: #ecfdf3;
  color: #067647;
}

.message.error {
  border-color: #efc8c8;
  background: #fff1f0;
  color: #9d2218;
}

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

.summary-grid .panel {
  min-width: 0;
  margin: 0;
  padding: 20px;
}

.summary span,
.summary strong {
  display: block;
}

.summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.summary strong {
  margin-top: 7px;
  color: var(--primary);
  font-size: clamp(21px, 5vw, 28px);
  line-height: 1.25;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.filter-row label {
  min-width: 0;
  margin: 0;
}

#monthTotals > p:not(.empty) {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 13px 0;
  border-bottom: 1px solid #e3eaf4;
}

#monthTotals > p:last-child {
  border-bottom: 0;
}

.record-list {
  display: grid;
  gap: 16px;
}

.record-list .record {
  margin: 0;
}

.record-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.record-head span:last-child {
  color: var(--primary);
  white-space: nowrap;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 15px 0;
}

.record-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid #e1e8f2;
  border-radius: 12px;
  background: #f7f9fc;
  overflow-wrap: anywhere;
}

.record-grid b {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.period-grid,
.period-points {
  display: grid;
  gap: 12px;
}

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

.period-grid label {
  min-width: 0;
  margin: 0;
}

.period-points {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.period-points div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--gradient-soft);
}

.period-points span,
.period-points strong {
  display: block;
}

.period-points span {
  color: var(--muted);
  font-size: 12px;
}

.period-points strong {
  margin-top: 5px;
  overflow-wrap: anywhere;
}

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

.stack .btn {
  width: 100%;
}

.link-button {
  min-height: 38px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 750;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.privacy-card .link-button + .link-button {
  margin-left: 14px;
}

dialog {
  width: min(calc(100% - 28px), 620px);
  max-height: min(82vh, 760px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 24px 70px rgba(3, 19, 47, 0.28);
}

dialog::backdrop {
  background: rgba(3, 19, 47, 0.62);
  backdrop-filter: blur(4px);
}

.dialog-content {
  padding: clamp(20px, 5vw, 32px);
}

.dialog-content p {
  color: var(--muted);
  font-size: 14px;
}

.notice-text {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--gradient-soft);
  color: var(--primary-dark) !important;
}

.consent {
  position: fixed;
  right: 14px;
  bottom: 14px;
  left: 14px;
  z-index: 20;
  display: grid;
  width: min(calc(100% - 28px), 704px);
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 55px rgba(3, 19, 47, 0.22);
}

.consent p {
  margin: 0 0 14px;
  color: var(--primary-dark);
  font-size: 13px;
}

.print-only {
  display: none;
}

.orca-brand {
  margin: 24px 0 0;
  padding: 14px 18px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.orca-brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.orca-brand img {
  display: block;
  width: clamp(168px, 32vw, 230px);
  max-width: 100%;
  height: auto;
  margin: 6px auto 0;
  object-fit: contain;
}

@media (max-width: 620px) {
  .app {
    width: 100%;
    margin: 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .top {
    min-height: 94px;
  }

  .period-grid,
  .period-points {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  .app-content {
    padding-right: 10px;
    padding-left: 10px;
  }

  .top {
    gap: 8px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .top-title { gap: 6px; }

  .top h1 { font-size: 22px; }

  .orca-mark { padding: 2px; }

  .orca-mark img {
    width: 34px;
    height: 34px;
  }

  .pill {
    min-width: 54px;
    min-height: 54px;
  }

  .tabs {
    gap: 5px;
    padding: 6px;
  }

  .tab {
    font-size: 14px;
  }

  .summary-grid,
  .filter-row,
  .record-grid {
    grid-template-columns: 1fr;
  }

  .filter-row .btn {
    width: 100%;
  }

  .button-row > .btn {
    flex: 1 1 100%;
  }

  .update-banner,
  .draft-box {
    align-items: stretch;
    flex-direction: column;
  }

  .update-banner .btn,
  .draft-box .btn {
    width: 100%;
  }

  .privacy-card .link-button {
    display: block;
    width: 100%;
  }

  .privacy-card .link-button + .link-button {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  .app {
    display: none;
  }

  .print-only {
    display: block;
    padding: 12mm;
  }

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

  td,
  th {
    padding: 5px;
    border: 1px solid #777;
    text-align: right;
  }

  td:first-child,
  th:first-child {
    text-align: left;
  }
}
