* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #e8e8e8;
  color: #333;
}

.admin-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  background: white;
  border-bottom: 1px solid #ddd;
  padding: 20px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.admin-header h1 {
  font-size: 24px;
  color: #333;
}

.admin-nav {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
}

.btn-secondary {
  background: #666;
  color: white;
}

.btn-secondary:hover {
  background: #555;
}

.btn-danger {
  background: #cc0000;
  color: white;
}

.btn-danger:hover {
  background: #990000;
}

.admin-main {
  flex: 1;
  padding: 5px 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.filter-section {
  background: white;
  padding: 5px 20px;
  border-radius: 8px;
  margin-bottom: 5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.filter-section h2 {
  font-size: 18px;
  margin-bottom: 5px;
}

.filter-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 16px;
  background: #f0f0f0;
  color: #333;
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.filter-btn:hover {
  background: #e0e0e0;
}

.filter-btn.active {
  background: #0066cc;
  color: white;
}

.range-label {
  font-size: 12px;
  color: #666;
  margin: 0;
}

.stats-section {
  background: white;
  padding: 5px 20px;
  border-radius: 8px;
  margin-bottom: 5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.stats-section h2 {
  font-size: 18px;
  margin-bottom: 5px;
}

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

.stats-table th,
.stats-table td {
  padding: 0;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.stats-table th {
  background: #e8e8e8;
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

.stats-table td.number {
  text-align: right;
  font-family: "Courier New", monospace;
}

.stats-table .total-row {
  background: #f9f9f9;
  font-weight: 600;
}

.link-action {
  color: #0066cc;
  text-decoration: none;
  font-size: 14px;
}

.link-action:hover {
  text-decoration: underline;
}

.table-image-preview {
  max-width: 60px;
  max-height: 60px;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
}

.stats-table td[data-field="og_image"] {
  padding: 2px;
  vertical-align: middle;
}

/* ===== ダッシュボードのテーブル ===== */
.stats-section .stats-table {
  table-layout: fixed;
  width: 100%;
}

.stats-section .stats-table td,
.stats-section .stats-table th {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ダッシュボード列幅 */
.stats-section .stats-table th:nth-child(1),
.stats-section .stats-table td:nth-child(1) {
  width: 8%;
}

.stats-section .stats-table th:nth-child(2),
.stats-section .stats-table td:nth-child(2) {
  width: 22%;
}

.stats-section .stats-table th:nth-child(3),
.stats-section .stats-table td:nth-child(3) {
  width: 12%;
}

.stats-section .stats-table th:nth-child(4),
.stats-section .stats-table td:nth-child(4) {
  width: 20%;
}

.stats-section .stats-table th:nth-child(5),
.stats-section .stats-table td:nth-child(5) {
  width: 16%;
  padding-right: 20px;
}

.stats-section .stats-table th:nth-child(6),
.stats-section .stats-table td:nth-child(6),
.stats-section .stats-table .total-row td:nth-child(6) {
  width: 10%;
  padding-right: 20px;
}


.stats-section .stats-table th:nth-child(7),
.stats-section .stats-table td:nth-child(7) {
  width: 7%;
  padding-left: 10px;
  text-align: center;
}

/* ===== リンク一覧のテーブル ===== */
.form-section .stats-table {
  table-layout: fixed;
  width: 100%;
}

.form-section .stats-table td,
.form-section .stats-table th {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  padding: 1px 5px;
}

/* リンク一覧列幅 */
.form-section .stats-table th:nth-child(1),
.form-section .stats-table td:nth-child(1) {
  width: 8%;
}

.form-section .stats-table th:nth-child(2),
.form-section .stats-table td:nth-child(2) {
  width: 17%;
}

.form-section .stats-table th:nth-child(3),
.form-section .stats-table td:nth-child(3) {
  width: 10%;
}

.form-section .stats-table th:nth-child(4),
.form-section .stats-table td:nth-child(4) {
  width: 16%;
}

.form-section .stats-table th:nth-child(5),
.form-section .stats-table td:nth-child(5) {
  width: 14%;
}

.form-section .stats-table th:nth-child(6),
.form-section .stats-table td:nth-child(6) {
  width: 21%;
  font-size: 12px;
}

.form-section .stats-table th:nth-child(7),
.form-section .stats-table td:nth-child(7) {
  width: 7%;
  text-align: center;
  vertical-align: middle;
}

.form-section .stats-table th:nth-child(8),
.form-section .stats-table td:nth-child(8) {
  width: 7%;
  text-align: center;
  vertical-align: middle;
}

/* og_title セルの表示を修正 */
.form-section .stats-table td[data-field="og_title"] {
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  max-width: 100%;
}

.graphs-section {
  background: white;
  padding: 5px 20px;
  border-radius: 8px;
  margin-bottom: 5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.graphs-section h2 {
  font-size: 18px;
  margin-bottom: 5px;
}

.graph-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.graph-item {
  position: relative;
  height: 300px;
}

.graph-item:first-child {
  grid-column: 1 / -1;
}

.graph-item h3 {
  font-size: 16px;
  margin-bottom: 15px;
}

.graph-item canvas {
  max-width: 100%;
  max-height: 250px;
}

.graph-item canvas {
  max-width: 100%;
}

@media (max-width: 768px) {
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .admin-main {
    padding: 20px;
  }

  .graph-grid {
    grid-template-columns: 1fr;
  }

  .filter-buttons {
    flex-direction: column;
  }

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

.detail-section {
  background: white;
  padding: 5px 20px;
  border-radius: 8px;
  margin-top: 5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.detail-section h2 {
  font-size: 18px;
  margin-bottom: 5px;
}

.detail-list {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 15px;
}

.detail-list dt {
  font-weight: 600;
  color: #666;
  padding: 8px 0;
}

.detail-list dd {
  padding: 8px 0;
  word-break: break-all;
}

.detail-list dd a {
  color: #0066cc;
  text-decoration: none;
}

.detail-list dd a:hover {
  text-decoration: underline;
}

.detail-list ul {
  list-style: none;
  padding-left: 0;
}

.detail-list li {
  padding: 4px 0;
}

.detail-list img {
  border-radius: 4px;
  border: 1px solid #ddd;
}
