/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1B6B93;
  --primary-dark: #145373;
  --primary-light: #2a8ab8;
  --dark: #2C3E50;
  --dark-secondary: #34495E;
  --light-bg: #ECF0F1;
  --white: #FFFFFF;
  --border: #D5DBDB;
  --text: #2C3E50;
  --text-secondary: #7F8C8D;
  --success: #27AE60;
  --warning: #F39C12;
  --danger: #E74C3C;
  --info: #3498DB;
  --purple: #8E44AD;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --radius: 8px;
  --radius-sm: 4px;
}

body {
  font-family: Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: var(--light-bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Header === */
.header {
  background: var(--primary);
  color: var(--white);
  padding: 0 1.5rem;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.header-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-status {
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

.header-status.online {
  background: rgba(39, 174, 96, 0.3);
}

.header-status.offline {
  background: rgba(231, 76, 60, 0.3);
}

/* === Tab Navigation === */
.tab-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.875rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  font-family: inherit;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

/* === Main Content === */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tab-panel {
  display: none;
}

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

/* === Panel Header === */
.panel-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.panel-header h2 {
  font-size: 1.3rem;
  color: var(--dark);
}

.panel-controls {
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
  flex-wrap: wrap;
}

/* === Cards === */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-title {
  font-size: 1rem;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* === Summary Cards === */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.summary-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
}

.summary-card .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--dark);
  margin: 0.25rem 0;
}

.summary-card .sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* === Tables === */
.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.data-table thead {
  background: var(--dark);
  color: var(--white);
}

.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--light-bg);
}

.data-table tbody tr:nth-child(even) {
  background: #F8F9FA;
}

.data-table tbody tr:hover {
  background: #EBF5FB;
}

/* === Badges === */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-new {
  background: #D6EAF8;
  color: #2471A3;
}

.badge-draft {
  background: #FEF9E7;
  color: #B7950B;
}

.badge-sent {
  background: #D5F5E3;
  color: #1E8449;
}

.badge-replied {
  background: #E8DAEF;
  color: #7D3C98;
}

.badge-booked {
  background: #FADBD8;
  color: #C0392B;
}

.badge-warning {
  background: #FEF9E7;
  color: #B7950B;
}

.badge-error {
  background: #FADBD8;
  color: #C0392B;
}

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--light-bg);
  color: var(--dark);
  border: 1px solid var(--border);
}

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

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

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

/* === Form Elements === */
.input-field {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.2s;
  width: 100%;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 107, 147, 0.1);
}

.input-small {
  width: 80px;
}

.textarea-field {
  resize: vertical;
  min-height: 100px;
}

select.input-field {
  width: auto;
  min-width: 160px;
}

/* === Prompts Grid === */
.prompts-grid {
  display: grid;
  gap: 1.25rem;
}

.prompt-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.prompt-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.prompt-card-header h3 {
  font-size: 1rem;
  color: var(--dark);
}

.prompt-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.prompt-card textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.prompt-card textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 107, 147, 0.1);
}

.prompt-card-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.prompt-stat {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.prompt-stat strong {
  color: var(--primary);
}

/* === Bar Chart (CSS) === */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  height: 220px;
  padding: 1rem 0.5rem 0;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.bar-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.bar-fill {
  width: 100%;
  max-width: 60px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  transition: height 0.5s ease;
  min-height: 4px;
}

.bar-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  text-align: center;
  word-break: keep-all;
}

/* === Settings === */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.followup-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.followup-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.followup-row label {
  min-width: 60px;
  font-size: 0.9rem;
}

.followup-row span {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--dark);
  color: var(--white);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 200;
}

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

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* === Footer === */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 2rem;
}

/* === Responsive === */
@media (max-width: 768px) {
  .header-inner {
    height: auto;
    padding: 0.75rem 0;
    flex-direction: column;
    gap: 0.5rem;
  }

  .header-title {
    font-size: 1rem;
  }

  .tab-nav {
    padding: 0 0.5rem;
  }

  .tab-btn {
    padding: 0.75rem 0.875rem;
    font-size: 0.8rem;
  }

  .main-content {
    padding: 1rem;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-controls {
    margin-left: 0;
    width: 100%;
  }

  .panel-controls .input-field {
    width: 100%;
  }

  .panel-controls select.input-field {
    width: 100%;
  }

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

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

  .bar-chart {
    gap: 0.75rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.5rem 0.625rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .summary-cards {
    grid-template-columns: 1fr;
  }
}
