/* ジラフ・コーポレーション AI統合ソーラープラットフォーム */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #1B6B3A;
  --primary-light: #2D8F52;
  --primary-dark: #0F4D28;
  --accent: #F5A623;
  --accent-light: #FFD080;
  --bg-main: #F0F4F1;
  --bg-card: #FFFFFF;
  --bg-sidebar: #0A2E18;
  --bg-sidebar-hover: #133D24;
  --text-primary: #1A2B22;
  --text-secondary: #5A6B62;
  --text-sidebar: #C5D8CC;
  --text-sidebar-active: #FFFFFF;
  --border: #D4DED8;
  --success: #27AE60;
  --warning: #F39C12;
  --danger: #E74C3C;
  --info: #2980B9;
  --shadow: 0 2px 12px rgba(15, 77, 40, 0.08);
  --shadow-hover: 0 4px 20px rgba(15, 77, 40, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: 260px;
  height: 100vh;
  background: var(--bg-sidebar);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.sidebar-logo .logo-text {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.sidebar-logo .logo-text small {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-sidebar);
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
  font-weight: 400;
  position: relative;
}

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

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

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer .env-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--success);
  background: rgba(39, 174, 96, 0.12);
  padding: 4px 10px;
  border-radius: 20px;
}

.sidebar-footer .env-badge::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Main content */
.main {
  margin-left: 260px;
  min-height: 100vh;
}

.topbar {
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-left h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-left .page-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-right .ai-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(27, 107, 58, 0.08), rgba(245, 166, 35, 0.08));
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
}

.topbar-right .ai-status::before {
  content: '🤖';
}

.topbar-right .user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.content {
  padding: 24px 32px;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

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

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
}

.kpi-card:nth-child(1)::after { background: var(--primary); }
.kpi-card:nth-child(2)::after { background: var(--accent); }
.kpi-card:nth-child(3)::after { background: var(--info); }
.kpi-card:nth-child(4)::after { background: var(--success); }

.kpi-card .kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.kpi-card .kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.kpi-card .kpi-icon {
  font-size: 20px;
}

.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-card .kpi-unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 2px;
}

.kpi-card .kpi-change {
  font-size: 12px;
  margin-top: 4px;
  font-weight: 500;
}

.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }

/* Grid layouts */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.grid-3-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.grid-1-3 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

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

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header .card-actions {
  display: flex;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* Chart containers */
.chart-container {
  width: 100%;
  height: 280px;
  position: relative;
}

.chart-container.tall {
  height: 360px;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

.data-table tr:hover {
  background: rgba(27, 107, 58, 0.03);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.normal { background: rgba(39, 174, 96, 0.1); color: var(--success); }
.status-badge.warning { background: rgba(243, 156, 18, 0.1); color: var(--warning); }
.status-badge.danger { background: rgba(231, 76, 60, 0.1); color: var(--danger); }
.status-badge.info { background: rgba(41, 128, 185, 0.1); color: var(--info); }
.status-badge.complete { background: rgba(39, 174, 96, 0.1); color: var(--success); }
.status-badge.progress { background: rgba(41, 128, 185, 0.1); color: var(--info); }
.status-badge.pending { background: rgba(243, 156, 18, 0.1); color: var(--warning); }
.status-badge.negotiation { background: rgba(155, 89, 182, 0.1); color: #9B59B6; }

/* AI Insight cards */
.ai-insight {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border-left: 3px solid;
  margin-bottom: 12px;
  transition: var(--transition);
  cursor: pointer;
}

.ai-insight:last-child { margin-bottom: 0; }

.ai-insight:hover {
  transform: translateX(4px);
}

.ai-insight.high {
  background: rgba(231, 76, 60, 0.05);
  border-color: var(--danger);
}

.ai-insight.medium {
  background: rgba(243, 156, 18, 0.05);
  border-color: var(--warning);
}

.ai-insight.low {
  background: rgba(41, 128, 185, 0.05);
  border-color: var(--info);
}

.ai-insight .insight-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ai-insight .insight-icon { font-size: 16px; }

.ai-insight .insight-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.ai-insight .insight-priority {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-insight .insight-detail {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.ai-insight .insight-action {
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-insight .insight-action::before {
  content: '→';
}

/* Progress bars */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1s ease;
}

.progress-bar .fill.green { background: var(--success); }
.progress-bar .fill.yellow { background: var(--warning); }
.progress-bar .fill.red { background: var(--danger); }
.progress-bar .fill.blue { background: var(--info); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

/* Simulation section */
.sim-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.sim-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sim-field select,
.sim-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: #fff;
  transition: var(--transition);
}

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

.sim-result {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(27, 107, 58, 0.05), rgba(245, 166, 35, 0.05));
  border-radius: var(--radius);
  border: 1px solid rgba(27, 107, 58, 0.15);
}

.sim-result-item {
  text-align: center;
}

.sim-result-item .sim-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.sim-result-item .sim-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Inventory meter */
.stock-meter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stock-meter .meter {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.stock-meter .meter .fill {
  height: 100%;
  border-radius: 3px;
}

.stock-meter .count {
  font-size: 12px;
  font-weight: 600;
  min-width: 24px;
  text-align: right;
}

/* Page sections */
.page-section {
  display: none;
}

.page-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tab navigation */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: rgba(27, 107, 58, 0.06);
  padding: 4px;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
  font-family: inherit;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Donut chart */
.donut-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px 0;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.donut-legend-item .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Scrollable container */
.scroll-y {
  max-height: 400px;
  overflow-y: auto;
}

.scroll-y::-webkit-scrollbar { width: 4px; }
.scroll-y::-webkit-scrollbar-track { background: transparent; }
.scroll-y::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* CO2 counter */
.co2-counter {
  text-align: center;
  padding: 30px 20px;
}

.co2-counter .big-number {
  font-size: 48px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.co2-counter .big-unit {
  font-size: 18px;
  font-weight: 500;
}

.co2-counter .sub-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* Weather widget */
.weather-widget {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #E8F5E9, #FFF8E1);
  border-radius: var(--radius-sm);
}

.weather-icon { font-size: 36px; }

.weather-info .temp {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.weather-info .desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.weather-solar {
  margin-left: auto;
  text-align: right;
}

.weather-solar .solar-val {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.weather-solar .solar-label {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: translateY(20px) scale(0.97);
  transition: all 0.3s ease;
}

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

.modal.modal-lg { max-width: 720px; }
.modal.modal-xl { max-width: 960px; }

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

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--bg-main);
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--danger);
  color: #fff;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 80px;
  right: 32px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 380px;
}

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

.toast-success { background: #fff; border-left: 4px solid var(--success); color: var(--text-primary); }
.toast-info { background: #fff; border-left: 4px solid var(--info); color: var(--text-primary); }
.toast-warning { background: #fff; border-left: 4px solid var(--warning); color: var(--text-primary); }
.toast-error { background: #fff; border-left: 4px solid var(--danger); color: var(--text-primary); }

/* Form elements in modals */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: #fff;
  transition: var(--transition);
}

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

.form-input:disabled {
  background: var(--bg-main);
  color: var(--text-secondary);
}

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

/* Filter select */
.filter-select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: inherit;
  color: var(--text-secondary);
  background: #fff;
  cursor: pointer;
  transition: var(--transition);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Clickable table rows */
.data-table tr[style*="cursor:pointer"]:hover {
  background: rgba(27, 107, 58, 0.06) !important;
}

.data-table tr[style*="cursor:pointer"]:hover td {
  color: var(--primary);
}

/* Print styles */
@media print {
  .sidebar, .topbar, .modal-footer, .modal-close, .modal-overlay { background: none; }
  .sidebar, .topbar { display: none !important; }
  .modal-overlay { position: static; background: none; backdrop-filter: none; }
  .modal { max-width: 100%; max-height: none; box-shadow: none; width: 100%; }
  .modal-footer { display: none !important; }
  body { overflow: visible !important; }
}

/* Responsive */
@media (max-width: 1400px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .sim-form { grid-template-columns: repeat(2, 1fr); }
  .sim-result { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  .sidebar { width: 72px; }
  .sidebar .logo-text,
  .sidebar .nav-section-title,
  .sidebar .nav-item span,
  .sidebar .nav-item .badge,
  .sidebar-footer { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 12px; }
  .sidebar .nav-item .nav-icon { margin: 0; }
  .sidebar-logo { justify-content: center; padding: 16px; }
  .main { margin-left: 72px; }
  .grid-2, .grid-3-1, .grid-1-3 { grid-template-columns: 1fr; }
}
