/* ===================================================
   LOGICTION - Design System
   =================================================== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* Color Palette */
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --primary-light: #93C5FD;
  --secondary: #10B981;
  --accent: #F59E0B;
  --danger: #EF4444;
  --warning: #F97316;
  --info: #06B6D4;

  /* Neutrals */
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Dark Sidebar */
  --sidebar-bg: #0F172A;
  --sidebar-hover: #1E293B;
  --sidebar-active: #1D4ED8;
  --sidebar-text: #94A3B8;
  --sidebar-text-active: #FFFFFF;
  --sidebar-border: #1E293B;

  /* Main Area */
  --page-bg: #F1F5F9;
  --card-bg: #FFFFFF;
  --card-border: #E2E8F0;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.12);

  /* Typography */
  --font-sans: 'Noto Sans JP', 'Inter', -apple-system, sans-serif;
  --font-mono: 'Fira Code', monospace;

  /* Spacing */
  --sidebar-width: 240px;
  --header-height: 56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--page-bg);
  color: var(--gray-800);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

/* ===== APP LAYOUT ===== */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--sidebar-border);
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.sidebar-logo {
  padding: 24px 16px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  background: rgba(15, 23, 42, 0.5);
}

.sidebar-logo img {
  margin-bottom: 12px;
}

.sidebar-logo h1 {
  font-size: 16px;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: 1px;
  line-height: 1.2;
}

.sidebar-logo span {
  display: block;
  font-size: 10px;
  color: var(--sidebar-text);
  font-weight: 500;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-section {
  padding: 12px 8px 4px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  user-select: none;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #CBD5E1;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 500;
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ===== MAIN CONTENT ===== */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== TOP HEADER ===== */
#header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 50;
}
#hamburger-btn { display: block; cursor: pointer; }

/* Sidebar collapsed state (Desktop/iPad) */
body.sidebar-collapsed #sidebar {
  width: 0 !important;
  min-width: 0 !important;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  border-right: none;
}

#header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
}

.header-spacer { flex: 1; }

.header-actions { display: flex; align-items: center; gap: 10px; }

/* ===== PAGE AREA ===== */
#page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== CARDS ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body { padding: 20px; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--card-shadow);
  transition: var(--transition);
}

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

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.stat-sub {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

.stat-up { color: var(--secondary); }
.stat-down { color: var(--danger); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  font-family: var(--font-sans);
  line-height: 1;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--secondary); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #EA580C; }
.btn-ghost { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* Payment buttons */
.pay-btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pay-btn {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
}
.pay-btn.cash { background: #FFF7ED; color: #C2410C; border-color: #FED7AA; }
.pay-btn.cash:hover, .pay-btn.cash.active { background: #F97316; color: white; border-color: #F97316; }
.pay-btn.card { background: #EFF6FF; color: #1D4ED8; border-color: #BFDBFE; }
.pay-btn.card:hover, .pay-btn.card.active { background: #3B82F6; color: white; border-color: #3B82F6; }
.pay-btn.transfer { background: #F0FDF4; color: #15803D; border-color: #BBF7D0; }
.pay-btn.transfer:hover, .pay-btn.transfer.active { background: #22C55E; color: white; border-color: #22C55E; }
.pay-btn.refund { background: #FFF1F2; color: #BE123C; border-color: #FECDD3; }
.pay-btn.refund:hover, .pay-btn.refund.active { background: #EF4444; color: white; border-color: #EF4444; }

/* ===== FORMS ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
}

.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--gray-800);
  background: white;
  transition: var(--transition);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea { resize: vertical; min-height: 80px; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

.data-table tr:hover td { background: var(--gray-50); }
.data-table tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.badge-blue { background: #EFF6FF; color: #1D4ED8; }
.badge-green { background: #F0FDF4; color: #15803D; }
.badge-yellow { background: #FFFBEB; color: #B45309; }
.badge-red { background: #FFF1F2; color: #BE123C; }
.badge-purple { background: #F5F3FF; color: #6D28D9; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.96) translateY(10px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 600; color: var(--gray-800); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--gray-600); background: var(--gray-100); }

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  font-family: var(--font-sans);
  white-space: nowrap;
}

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

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

/* ===== CALENDAR ===== */
.calendar { width: 100%; }

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-title { font-size: 16px; font-weight: 700; color: var(--gray-800); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-day-label {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  padding: 4px;
  text-transform: uppercase;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-700);
  transition: var(--transition);
  position: relative;
  min-height: 36px;
  gap: 2px;
}

.cal-day:hover { background: var(--gray-100); }
.cal-day.today { background: var(--primary); color: white; font-weight: 700; }
.cal-day.has-visits::after {
  content: '';
  width: 4px;
  height: 4px;
  background: var(--secondary);
  border-radius: 50%;
  position: absolute;
  bottom: 3px;
}
.cal-day.today.has-visits::after { background: white; }
.cal-day.other-month { color: var(--gray-300); }
.cal-day.selected { background: #EFF6FF; color: var(--primary); border: 2px solid var(--primary); font-weight: 600; }

/* ===== SEARCH ===== */
.search-wrap { position: relative; }
.search-input {
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--gray-800);
  width: 100%;
  outline: none;
  transition: var(--transition);
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--gray-400);
}

/* ===== DROPDOWN SUGGESTION ===== */
.suggestion-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow-hover);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 2px;
}

.suggestion-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
}
.suggestion-item:hover { background: var(--gray-50); }
.suggestion-item:last-child { border-bottom: none; }

/* ===== ALERT / NOTIFICATION ===== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid;
}
.alert-info { background: #EFF6FF; border-color: #BFDBFE; color: #1E40AF; }
.alert-success { background: #F0FDF4; border-color: #BBF7D0; color: #166534; }
.alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.alert-danger { background: #FFF1F2; border-color: #FECDD3; color: #9F1239; }

/* ===== PAGE TITLE ROW ===== */
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
}

.page-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ===== SECTION DIVIDER ===== */
.section-divide {
  height: 1px;
  background: var(--gray-200);
  margin: 16px 0;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--gray-400);
  gap: 12px;
  text-align: center;
}

.empty-state-icon { font-size: 48px; opacity: 0.6; }
.empty-state-text { font-size: 14px; font-weight: 500; color: var(--gray-500); }
.empty-state-sub { font-size: 12px; color: var(--gray-400); }

/* ===== TAG ===== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--gray-900);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: toast-in 0.3s ease;
  pointer-events: all;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.success { background: #15803D; }
.toast.danger  { background: #BE123C; }
.toast.warning { background: #B45309; }

@keyframes toast-in {
  from { transform: translateX(100px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* ===== METRIC TABLE ===== */
.metric-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.metric-table th, .metric-table td {
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--gray-100);
  text-align: right;
}
.metric-table th { text-align: left; font-weight: 600; color: var(--gray-600); background: var(--gray-50); font-size: 11px; }
.metric-table td:first-child { text-align: left; color: var(--gray-700); }

/* ===== LOADING ===== */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE (Multidevice adjustments) ===== */

/* --- Mobile / Tablet (max 768px) --- */
@media (max-width: 768px) {
  :root { --sidebar-width: 240px; }
  
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1100;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 30px rgba(0,0,0,0.15);
  }

  #sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1050;
  }
  #sidebar-backdrop.active { display: block; }

  #hamburger-btn { display: block !important; }
  .sidebar-close-btn { display: block !important; }

  #header { padding: 0 16px; }
  #header h2 { font-size: 14px; }
  #page-content { padding: 12px; gap: 16px; }

  /* Tables optimization */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
  }

  /* Grid optimization */
  .stats-grid { grid-template-columns: 1fr !important; }

  /* Card optimization */
  .card-header { padding: 12px 16px; }
  .card-body { padding: 16px; }

  /* Modal optimization */
  .modal { max-height: 95vh; border-radius: var(--radius-md); }
  .modal-body { padding: 16px; }
  .form-grid { grid-template-columns: 1fr !important; }

  /* Notification dropdown on Mobile */
  #notif-dropdown {
    width: calc(100vw - 32px);
    right: -60px;
  }

  #main { margin-left: 0 !important; }
}

/* ===== MENU GROUP ACCORDION ===== */
.menu-group {
  margin-bottom: 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: white;
  overflow: hidden;
  transition: var(--transition);
}

.menu-group-header {
  padding: 10px 14px;
  background: var(--gray-50);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  user-select: none;
  transition: var(--transition);
}

.menu-group-header:hover {
  background: var(--gray-100);
  color: var(--primary);
}

.menu-group-content {
  padding: 12px;
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--gray-200);
  background: white;
  animation: slideDown 0.2s ease-out;
}

.menu-group.open .menu-group-content {
  display: flex;
}

.menu-group-icon {
  font-size: 10px;
  color: var(--gray-400);
  transition: transform 0.2s;
}

.menu-group.open .menu-group-icon {
  transform: rotate(180deg);
  color: var(--primary);
}

.menu-group-badge {
  font-size: 10px;
  background: var(--gray-200);
  color: var(--gray-600);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 8px;
  font-weight: 400;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== KARTE ENHANCEMENTS ===== */
.sketch-container {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: #fff;
  position: relative;
  touch-action: none; /* iPadでのスクロール防止 */
  overflow: hidden;
  margin-bottom: 10px;
}

.sketch-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}

.tool-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  background: white;
  border: 1px solid var(--gray-300);
  font-size: 14px;
  transition: var(--transition);
}
.tool-btn:hover { background: var(--gray-50); }
.tool-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.photo-upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  background: var(--gray-50);
  transition: var(--transition);
  color: var(--gray-500);
}
.photo-upload-zone:hover { border-color: var(--primary); color: var(--primary); background: var(--gray-100); }

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.photo-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.photo-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
}

.record-visuals {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.record-sketch {
  max-width: 100%;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-md);
  background: white;
}

.record-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.record-photo-item {
  aspect-ratio: 4/3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--gray-100);
}

.record-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

.record-photo-item:hover img {
  transform: scale(1.05);
}

/* --- Very Small Screen (max 480px) --- */
@media (max-width: 480px) {
  .stat-value { font-size: 20px !important; }
  .page-title { font-size: 18px !important; }
  .btn { font-size: 13px; padding: 6px 12px; }
}

/* ===== DARK MODE ===== */
body.dark-mode {
  --page-bg: #0f172a;
  --card-bg: #1e293b;
  --card-border: #334155;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.4);

  --gray-50: #1e293b;
  --gray-100: #334155;
  --gray-200: #475569;
  --gray-300: #64748b;
  --gray-400: #94a3b8;
  --gray-500: #cbd5e1;
  --gray-600: #e2e8f0;
  --gray-700: #f1f5f9;
  --gray-800: #f8fafc;
  --gray-900: #ffffff;
}

body.dark-mode #header {
  background: #1e293b;
  border-bottom-color: #334155;
}

body.dark-mode .modal {
  background: #1e293b;
  border: 1px solid #334155;
}

body.dark-mode .modal-overlay {
  background: rgba(0,0,0,0.7);
}

body.dark-mode .form-input,
body.dark-mode .form-select,
body.dark-mode .form-textarea {
  background: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}

body.dark-mode .form-input:focus,
body.dark-mode .form-select:focus,
body.dark-mode .form-textarea:focus {
  border-color: var(--primary);
}

body.dark-mode .data-table thead {
  background: #334155;
}

body.dark-mode .data-table tbody tr {
  border-bottom-color: #334155;
}

body.dark-mode .data-table tbody tr:hover {
  background: #334155;
}

body.dark-mode .alert {
  border-color: #475569;
}

body.dark-mode .alert-info { background: #1e3a5f; color: #93c5fd; }
body.dark-mode .alert-warning { background: #451a03; color: #fcd34d; }
body.dark-mode .alert-danger { background: #450a0a; color: #fca5a5; }
body.dark-mode .alert-success { background: #052e16; color: #86efac; }

body.dark-mode .tabs {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .tab-btn {
  color: #94a3b8;
}

body.dark-mode .tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

body.dark-mode .stat-card {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .search-input {
  background: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}

body.dark-mode .progress-bar {
  background: #334155;
}

body.dark-mode .btn-secondary {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

body.dark-mode .btn-ghost {
  color: #94a3b8;
}
body.dark-mode .btn-ghost:hover {
  background: #334155;
}

/* Dark mode toggle button */
.dark-mode-toggle {
  background: none;
  border: 1px solid var(--gray-300);
  border-radius: 99px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
  color: var(--gray-600);
}
.dark-mode-toggle:hover {
  background: var(--gray-100);
}
body.dark-mode .dark-mode-toggle {
  border-color: #475569;
  color: #fcd34d;
}
body.dark-mode .dark-mode-toggle:hover {
  background: #334155;
}

/* ============================================================
   📱 スマホ最適化 (モバイルファースト対応)
   ============================================================ */
@media (max-width: 768px) {
  /* サイドバー: 既存のz-index(1100)・transformを尊重（重複定義しない） */
  #main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* ヘッダー */
  #header {
    padding: 10px 12px;
  }
  #header-clock { display: none; }
  .header-actions { gap: 6px; }

  /* コンテンツ */
  #page-content {
    padding: 12px !important;
  }

  /* グリッドを1列に */
  .form-grid { grid-template-columns: 1fr !important; }
  .grid-2 { grid-template-columns: 1fr !important; }
  .grid-3 { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:300px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 300px"] { grid-template-columns: 1fr !important; }

  /* テーブル: スクロール対応 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 600px; }

  /* カード */
  .card { margin-bottom: 12px; }
  .card-body { padding: 14px !important; }

  /* ボタン */
  .btn-lg { padding: 10px 16px !important; font-size: 14px !important; }
  .page-title-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }
  .page-title-row > div:last-child {
    width: 100%;
    flex-wrap: wrap;
  }

  /* モーダル */
  .modal { width: 95vw !important; max-width: none !important; margin: 10px; }

  /* ページタイトル */
  .page-title { font-size: 18px !important; }
}

@media (max-width: 480px) {
  #page-content { padding: 8px !important; }
  .card-header { padding: 12px 14px !important; }
  .btn { padding: 7px 12px !important; font-size: 12px; }
  .badge { font-size: 10px; }
}

/* ============================================================
   💀 スケルトンスクリーン
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
}

.skeleton-title {
  height: 18px;
  width: 40%;
  margin-bottom: 12px;
}

.skeleton-line {
  height: 12px;
  margin-bottom: 8px;
}

.skeleton-line.w-full { width: 100%; }
.skeleton-line.w-3q  { width: 75%; }
.skeleton-line.w-half { width: 50%; }

.skeleton-kpi {
  height: 80px;
  border-radius: var(--radius-md);
}

.skeleton-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

/* ダークモード対応 */
body.dark-mode .skeleton {
  background: linear-gradient(90deg, #334155 25%, #1e293b 50%, #334155 75%);
  background-size: 200% 100%;
}

/* ============================================================
   📱 スマートフォン最適化 (max-width: 480px)
   ============================================================ */
@media (max-width: 480px) {
  /* タップ領域（ボタン・フォーム）の拡大 */
  .form-input, .form-select, .form-textarea, .btn {
    font-size: 14px;
    padding: 12px 16px;
  }
  .form-textarea { min-height: 100px; }
  
  /* 決済ボタン等の横並び調整 */
  .pay-btn-group { display: flex; flex-wrap: wrap; gap: 8px; }
  .pay-btn { padding: 12px 14px; flex: 1; min-width: 45%; text-align: center; justify-content: center; }
  
  /* モーダルのフルスクリーン化（スマホネイティブ風） */
  .modal {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    transform: none !important;
  }
  .modal-overlay { padding: 0; }
  .modal-header { 
    padding: 16px; 
    position: sticky; 
    top: 0; 
    background: white; 
    z-index: 10; 
    border-bottom: 1px solid var(--gray-200); 
  }
  .modal-body { 
    padding: 16px; 
    flex: 1; 
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; 
  }
  .modal-footer { 
    padding: 16px; 
    position: sticky; 
    bottom: 0; 
    background: white; 
    z-index: 10; 
    border-top: 1px solid var(--gray-200); 
  }
  
  /* 固定幅要素（キャンバス等）を画面幅に収める */
  .sketch-container canvas {
    max-width: 100% !important;
    height: auto !important;
  }

  /* ページタイトル周りのレイアウト崩れ防止 */
  .page-title-row { flex-direction: column; align-items: flex-start; gap: 16px; }
  .page-title-row > div:last-child { width: 100%; display: flex; gap: 8px; justify-content: space-between; }
  .page-title-row .btn { flex: 1; justify-content: center; }

  /* テーブルの横スクロール強調（シャドウ追加） */
  .table-wrap {
    box-shadow: inset -10px 0 10px -10px rgba(0,0,0,0.1);
  }
}
