:root {
  --bg: #edf8fd;
  --panel: #ffffff;
  --panel-2: #e4f5fb;
  --text: #07324f;
  --muted: #54778d;
  --line: #bee2f1;
  --primary: #0093d2;
  --primary-dark: #0069a9;
  --primary-soft: #d8f2fb;
  --cyan: #39b9df;
  --green: #148568;
  --red: #cc3f4f;
  --amber: #b7791f;
  --ink-soft: #28536b;
  --shadow: 0 12px 30px rgba(0, 116, 170, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: linear-gradient(90deg, #ffffff 0%, #f4fbff 56%, #e4f6fc 100%);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 92px;
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  align-items: center;
  display: flex;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  background: #ffffff;
  border: 1px solid #c7edf7;
  border-radius: 10px;
  box-shadow: 0 6px 14px rgba(0, 133, 190, 0.12);
  display: block;
  height: 72px !important;
  max-height: 72px;
  max-width: 72px;
  object-fit: contain;
  padding: 3px;
  width: 72px !important;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  margin: 0;
}

.period-status {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.topbar-actions,
.form-actions,
.table-actions,
.ranking-switcher {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary,
.secondary,
.ghost,
.danger,
.icon-button {
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 12px;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.ghost {
  background: #e7f6fb;
  color: var(--ink-soft);
}

.danger {
  background: #f8dddd;
  color: var(--red);
}

.icon-button {
  align-items: center;
  background: #e7f6fb;
  color: var(--text);
  display: inline-flex;
  font-size: 20px;
  justify-content: center;
  min-width: 38px;
  padding: 0;
}

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 92px);
}

.sidebar {
  background: #0069a9;
  border-right: 1px solid #005c94;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px;
}

.nav-item {
  background: transparent;
  border-radius: 8px;
  color: #e8f8ff;
  min-height: 40px;
  padding: 10px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #ffffff;
  color: var(--primary-dark);
}

.workspace {
  min-width: 0;
  padding: 18px;
}

.filter-panel,
.section,
.input-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filter-panel {
  margin-bottom: 16px;
  padding: 14px;
}

.filter-grid,
.report-form,
.calculator-grid {
  display: grid;
  gap: 12px;
}

.filter-grid {
  grid-template-columns: repeat(9, minmax(130px, 1fr));
}

label {
  color: var(--muted);
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input[readonly] {
  background: var(--panel-2);
  color: var(--ink-soft);
}

.view-root {
  display: grid;
  gap: 16px;
}

.section {
  overflow: hidden;
}

.section-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 16px;
}

.section-header h2,
.section-header h3 {
  font-size: 18px;
  line-height: 1.3;
  margin: 0;
}

.section-header p {
  color: var(--muted);
  margin: 4px 0 0;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(8, minmax(140px, 1fr));
}

.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.summary-card .label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.summary-card .value {
  display: block;
  font-size: 22px;
  font-weight: 800;
  margin-top: 8px;
}

.summary-card.good .value {
  color: var(--green);
}

.summary-card.bad .value {
  color: var(--red);
}

.table-wrap {
  max-height: calc(100vh - 260px);
  overflow: auto;
  scrollbar-gutter: stable;
  width: 100%;
}

table {
  border-collapse: collapse;
  min-width: 1120px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: right;
  white-space: nowrap;
}

th {
  background: #e1f4fb;
  box-shadow: 0 1px 0 var(--line), 0 6px 12px rgba(0, 105, 169, 0.08);
  color: var(--ink-soft);
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
}

td.text,
th.text {
  text-align: left;
}

tbody tr:hover {
  background: #f8fafc;
}

.total-row td {
  background: #d7f2fb;
  font-weight: 800;
}

.negative {
  color: var(--red);
  font-weight: 800;
}

.positive {
  color: var(--green);
  font-weight: 800;
}

.warning {
  color: var(--amber);
  font-weight: 800;
}

.status-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  min-width: 64px;
  padding: 5px 9px;
  justify-content: center;
}

.status-good {
  background: #dbf3e7;
  color: var(--green);
}

.status-danger {
  background: #f8dddd;
  color: var(--red);
}

.status-warning {
  background: #f8edcf;
  color: var(--amber);
}

.status-neutral {
  background: #e6ebf0;
  color: var(--ink-soft);
}

.split-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rank-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
}

.compact-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.compact-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  padding: 8px 0;
}

.compact-row:last-child {
  border-bottom: 0;
}

.compact-row strong,
.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.input-panel {
  padding: 16px;
}

.report-form {
  grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.report-form .wide {
  grid-column: span 2;
}

.report-form .full {
  grid-column: 1 / -1;
}

.form-error {
  color: var(--red);
  font-weight: 700;
  margin: 0;
}

.modal-backdrop {
  align-items: center;
  background: rgba(12, 20, 28, 0.45);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
  max-width: 720px;
  width: 100%;
}

.modal-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px;
}

.modal-header h2 {
  font-size: 18px;
  margin: 0;
}

.calculator-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 16px;
}

.calculator-grid .form-error,
.calculator-grid .form-actions {
  grid-column: 1 / -1;
}

.affixed-input {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  overflow: hidden;
}

.affixed-input span {
  background: var(--panel-2);
  color: var(--ink-soft);
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-width: 38px;
  padding: 9px;
}

.affixed-input input {
  border: 0;
  border-radius: 0;
}

.empty-state {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-item {
    flex: 0 0 auto;
  }

  .filter-grid,
  .summary-grid,
  .rank-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    padding: 12px;
  }

  .table-wrap {
    max-height: calc(100vh - 220px);
  }

  .filter-grid,
  .summary-grid,
  .split-grid,
  .rank-grid,
  .report-form,
  .calculator-grid {
    grid-template-columns: 1fr;
  }

  .report-form .wide,
  .report-form .full {
    grid-column: auto;
  }
}


.copy-column-button {
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 900;
  min-height: 0;
  padding: 0;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.copy-column-button:hover {
  color: var(--primary-dark);
}

.copyable-header {
  cursor: pointer;
}

.copy-toast {
  background: var(--primary-dark);
  border-radius: 8px;
  bottom: 18px;
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  opacity: 0;
  padding: 10px 14px;
  position: fixed;
  right: 18px;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 9999;
}

.copy-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.copy-toast.bad {
  background: var(--red);
}


.daily-copy-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.daily-copy-button {
  font-size: 13px;
  font-weight: 900;
  min-width: 112px;
}
