:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --bg-color: #F3F4F6;
  --card-bg: rgba(255, 255, 255, 0.9);
  --text-main: #111827;
  --text-muted: #6B7280;
  
  /* Status Colors */
  --status-available-bg: #E5E7EB;
  --status-available-text: #374151;
  --status-waiting-bg: #DBEAFE;
  --status-waiting-text: #1D4ED8;
  --status-progress-bg: #FEF3C7;
  --status-progress-text: #B45309;
  --status-done-bg: #D1FAE5;
  --status-done-text: #047857;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  background-color: var(--bg-color);
  background-image: radial-gradient(#E5E7EB 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--text-main);
  min-height: 100vh;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.app-header {
  margin-bottom: 2.5rem;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.025em;
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  padding: 1.25rem;
  border-radius: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.5);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.slot-card {
  background: var(--card-bg);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255,255,255,0.8);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Status-specific card styling */
.slot-card[data-status="available"] { border-top: 4px solid var(--status-available-text); }
.slot-card[data-status="waiting"] { border-top: 4px solid var(--status-waiting-text); }
.slot-card[data-status="in_progress"] { border-top: 4px solid var(--status-progress-text); }
.slot-card[data-status="done"] { border-top: 4px solid var(--status-done-text); opacity: 0.6; }

.slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slot-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.delete-slot-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}
.delete-slot-btn:hover {
  background: #FEE2E2;
  color: #EF4444;
}

/* Modal Styles */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: var(--card-bg);
  width: 100%;
  max-width: 500px;
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  border: 1px solid rgba(255,255,255,0.8);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-size: 1.25rem;
  color: var(--text-main);
  margin: 0;
}

.close-modal-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 32px;
}
.close-modal-btn:hover {
  color: var(--text-main);
}

.setting-section {
  display: flex; flex-direction: column;
}

.setting-section h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }

.input-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 100px;
}

.input-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.input-group input {
  padding: 0.5rem;
  border: 1px solid #D1D5DB;
  border-radius: 0.5rem;
  font-family: inherit;
}
.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.setting-divider {
  height: 1px;
  background: #E5E7EB;
  margin: 1.5rem 0;
}

.slot-time {
  font-size: 1.25rem;
  font-weight: 800;
}

/* Print Modal & Ticket Styles */
.text-center { text-align: center; }
.mt-4 { margin-top: 1rem; }

.train-ticket {
    position: relative;
    width: 600px;
    height: 300px;
    background-color: #E6BACD; /* Sakura pink */
    background-image: radial-gradient(#d4a3b8 1px, transparent 1px);
    background-size: 15px 15px; /* Subtle pattern */
    color: #000;
    font-family: 'Noto Sans JP', sans-serif;
    overflow: hidden;
    margin: 0 auto;
    font-weight: 800;
    border: 1px solid #000;
}

.train-ticket * {
    position: absolute;
    color: #000;
    line-height: 1.2;
}

.tt-日原 {
    top: 10px; left: 30px;
    font-size: 110px;
    letter-spacing: 20px;
}

.tt-月詠町 {
    bottom: 0px; right: 20px;
    font-size: 100px;
    letter-spacing: 20px;
}

.tt-arrow {
    top: 50%; left: 45%;
    transform: translate(-50%, -50%);
    width: 80px; height: 80px;
}

.tt-top-right {
    top: 20px; right: 20px;
    text-align: right;
    width: auto;
}

.tt-railway { 
    position: static;
    font-size: 30px; 
    margin-bottom: 5px; 
    letter-spacing: 4px; 
}

.tt-details { 
    position: static;
    font-size: 20px; 
    text-align: left; 
    margin-left: auto; 
    width: max-content; 
    font-weight: 600;
}

.tt-bottom-left {
    bottom: 25px; left: 30px;
    width: auto;
}

.tt-line {
    width: 250px;
    height: 6px;
    background-color: #000;
    position: static;
}

.tt-number {
    position: static;
    font-size: 70px;
    letter-spacing: 5px;
    line-height: 1;
    margin-top: 5px;
}

.tt-bottom-center {
    bottom: 15px;
    left: 45%;
    transform: translateX(-50%);
    font-size: 20px;
    white-space: nowrap;
}

.tt-time {
    top: 15px;
    left: 45%;
    transform: translateX(-50%);
    font-size: 16px;
    color: #333;
}

.tt-qr {
    bottom: 30px;
    left: 200px;
    width: 80px;
    height: 80px;
    background: white;
    padding: 4px;
    border: 1px solid #000;
}

.tt-qr canvas, .tt-qr img {
    position: static;
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Back side */
.ticket-back-side {
    width: 600px;
    height: 300px;
    background-color: #FFF;
    color: #000;
    font-family: 'Noto Sans JP', sans-serif;
    border: 2px dashed #9ca3af;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0 auto;
}

.back-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.back-number {
    font-size: 3rem;
    font-weight: 900;
    font-family: monospace;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.back-time {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.back-qr {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.back-note {
    font-size: 0.875rem;
    color: #4B5563;
}

/* Print styles */
@media print {
  body {
    background: white;
    visibility: hidden;
  }
  .app-container, .modal.hidden {
    display: none !important;
  }
  #print-modal, #print-modal.modal {
    visibility: visible;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: white;
    box-shadow: none;
    align-items: flex-start;
  }
  .modal-content.ticket-print-content {
    box-shadow: none;
    border: none;
    margin: 0;
    padding: 0;
  }
  .hide-on-print {
    display: none !important;
  }
  .train-ticket {
      margin: 0;
  }
}


.slot-status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Badge colors */
.slot-card[data-status="available"] .slot-status-badge {
  background-color: var(--status-available-bg);
  color: var(--status-available-text);
}
.slot-card[data-status="waiting"] .slot-status-badge {
  background-color: var(--status-waiting-bg);
  color: var(--status-waiting-text);
}
.slot-card[data-status="in_progress"] .slot-status-badge {
  background-color: var(--status-progress-bg);
  color: var(--status-progress-text);
}
.slot-card[data-status="done"] .slot-status-badge {
  background-color: var(--status-done-bg);
  color: var(--status-done-text);
}

.ticket-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #F9FAFB;
  padding: 0.75rem;
  border-radius: 0.5rem;
}

.ticket-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.ticket-number {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text-main);
  font-family: monospace;
}

.slot-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 0.5rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s;
  padding: 0.75rem 1rem;
  width: 100%;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover { background-color: var(--primary-hover); transform: scale(1.02); }

.btn-reception {
  background-color: var(--status-waiting-text);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(29, 78, 216, 0.39);
}
.btn-reception:hover { background-color: #1e40af; transform: translateY(-2px); }

.btn-attend {
  background-color: var(--status-progress-text);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(180, 83, 9, 0.39);
}
.btn-attend:hover { background-color: #92400e; transform: translateY(-2px); }

.btn-complete {
  background-color: var(--status-done-text);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(4, 120, 87, 0.39);
}
.btn-complete:hover { background-color: #065f46; transform: translateY(-2px); }

.btn-undo {
  background-color: transparent;
  color: var(--text-muted);
  text-decoration: underline;
  width: auto;
  padding: 0.75rem 0.5rem;
  font-size: 0.875rem;
}
.btn-undo:hover { color: var(--text-main); }

.btn-outline {
  background: transparent;
  border: 1px solid #D1D5DB;
  color: var(--text-main);
  padding: 0.5rem 1rem;
}
.btn-outline:hover {
  background: #F3F4F6;
  border-color: #9CA3AF;
}

/* Animations */
@keyframes pop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.slot-card {
  animation: pop 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Stagger animations */
.slot-card:nth-child(n) { animation-delay: calc(n * 0.03s); }

@media (max-width: 640px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}
