/* DTS - Digital Track Solution - App Styles */
:root {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar: #f8f9fa;
  --bg-topbar: #e84b1c;
  --border: #e2e6ea;
  --border-sidebar: #dee2e6;
  --accent-blue: #2563eb;
  --accent-cyan: #0891b2;
  --accent-green: #16a34a;
  --accent-orange: #ea580c;
  --accent-red: #e84b1c;
  --accent-purple: #7c3aed;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-sidebar: #495057;
  --text-sidebar-muted: #868e96;
  --shadow-card: 0 1px 4px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Helvetica Neue', 'Noto Sans JP', Arial, sans-serif;
  font-size: 13px;
  height: 100vh;
  overflow: hidden;
}
/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f0f2f5; }
::-webkit-scrollbar-thumb { background: #c1c9d2; border-radius: 3px; }

/* Layout */
#app { display: flex; height: 100vh; }
#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease;
  flex-shrink: 0;
}
#sidebar.collapsed {
  width: 56px;
  min-width: 56px;
}
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#topbar {
  height: 48px;
  background: var(--bg-topbar);
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(232,75,28,0.3);
}
#content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Sidebar logo */
.sidebar-logo {
  height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-sidebar);
  display: flex;
  align-items: center;
  gap: 10px;
  background: #e84b1c;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(232,75,28,0.3);
}
.logo-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.logo-text-wrap { overflow: hidden; white-space: nowrap; transition: opacity 0.2s, max-width 0.25s; max-width: 180px; }
#sidebar.collapsed .logo-text-wrap { opacity: 0; max-width: 0; }
.logo-text { font-size: 13px; font-weight: 700; color: #ffffff; line-height: 1.2; }
.logo-sub { font-size: 9px; color: rgba(255,255,255,0.75); }

/* Sidebar nav */
.nav-section { overflow-y: auto; flex: 1; padding-bottom: 8px; }
.nav-group-label {
  font-size: 10px;
  color: var(--text-sidebar-muted);
  padding: 12px 16px 4px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}
#sidebar.collapsed .nav-group-label { opacity: 0; height: 0; padding: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  color: var(--text-sidebar);
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  font-size: 12px;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(232,75,28,0.07); color: #e84b1c; }
.nav-item.active {
  color: #e84b1c;
  background: rgba(232,75,28,0.1);
  border-left-color: #e84b1c;
  font-weight: 600;
}
.nav-item i { width: 14px; text-align: center; font-size: 11px; flex-shrink: 0; }
.nav-parent {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: #343a40;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}
.nav-parent:hover { background: rgba(232,75,28,0.05); color: #e84b1c; }
.nav-parent > i:first-child { width: 14px; text-align: center; font-size: 11px; flex-shrink: 0; color: #e84b1c; }
.nav-parent i.chevron { margin-left: auto; font-size: 9px; transition: transform 0.2s; color: var(--text-sidebar-muted); flex-shrink: 0; }
.nav-parent.open i.chevron { transform: rotate(180deg); }
#sidebar.collapsed .nav-parent i.chevron { display: none; }
#sidebar.collapsed .nav-parent span { display: none; }
.nav-children { display: none; }
.nav-children.show { display: block; }
#sidebar.collapsed .nav-children { display: none !important; }
.nav-child {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 32px;
  color: var(--text-sidebar);
  cursor: pointer;
  font-size: 10.5px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  white-space: normal;
  word-break: keep-all;
  line-height: 1.3;
}
.nav-child:hover { background: rgba(232,75,28,0.07); color: #e84b1c; }
.nav-child.active { color: #e84b1c; background: rgba(232,75,28,0.1); border-left-color: #e84b1c; font-weight: 600; }
.nav-child i { width: 12px; text-align: center; font-size: 10px; flex-shrink: 0; color: #e84b1c; }

/* Topbar */
.top-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.85);
}
.toggle-switch {
  width: 36px;
  height: 18px;
  background: rgba(255,255,255,0.3);
  border-radius: 9px;
  position: relative;
  cursor: pointer;
}
.toggle-knob {
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  right: 2px;
  transition: right 0.2s;
}
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  font-size: 11px;
  color: #ffffff;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.card-title {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.stat-sub {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.page-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--accent-red);
  cursor: pointer;
  margin-bottom: 6px;
}
.back-btn:hover { text-decoration: underline; }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-card);
}
.filter-input {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text-primary);
  font-size: 12px;
  width: 130px;
}
.filter-select {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text-primary);
  font-size: 12px;
}
.filter-sep { color: var(--text-muted); }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--accent-red); color: white; }
.btn-primary:hover { background: #c73d17; }
.btn-success { background: var(--accent-green); color: white; }
.btn-success:hover { background: #15803d; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent-red); color: var(--accent-red); }

/* Table */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f8fafc;
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text-primary); }
thead th.sort-asc .sort-icon::after { content: ' ▲'; }
thead th.sort-desc .sort-icon::after { content: ' ▼'; }
tbody tr {
  border-bottom: 1px solid rgba(226,230,234,0.7);
  transition: background 0.1s;
}
tbody tr:hover { background: rgba(232,75,28,0.04); }
tbody td {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
}
tbody td.muted { color: var(--text-secondary); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  font-size: 11px;
  color: var(--text-secondary);
}
.page-btns { display: flex; gap: 4px; align-items: center; }
.page-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 11px;
  transition: all 0.15s;
}
.page-btn:hover { border-color: var(--accent-red); color: var(--accent-red); }
.page-btn.active { background: var(--accent-red); border-color: var(--accent-red); color: white; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Alert badge */
.alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}
.alert-critical { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.alert-warning { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.alert-ok { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }

/* Donut legend */
.donut-legend { display: flex; flex-direction: column; gap: 4px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-label { color: var(--text-secondary); flex: 1; }
.legend-val { color: var(--text-primary); font-weight: 600; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: var(--text-primary); border-color: var(--border); }
.tab.active { background: var(--accent-red); color: white; border-color: var(--accent-red); }

/* Progress bar */
.progress-bar {
  height: 6px;
  background: #e2e6ea;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s; }

/* KPI row */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2,1fr); } }

/* Section title */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Hidden pages */
.page { display: none; }
.page.active { display: block; }

/* Trend indicator */
.trend-up { color: #f87171; font-size: 10px; }
.trend-down { color: #34d399; font-size: 10px; }

/* Bar chart container */
.chart-container { position: relative; }

/* Tooltip */
.tip {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Status dot */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.dot-green { background: var(--accent-green); }
.dot-yellow { background: var(--accent-orange); }
.dot-red { background: var(--accent-red); }

/* Table sort icon */
.sort-icon { font-size: 9px; margin-left: 3px; opacity: 0.5; }

/* Sidebar bottom */
.sidebar-bottom {
  padding: 10px 12px;
  border-top: 1px solid var(--border-sidebar);
  font-size: 10px;
  color: var(--text-sidebar-muted);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}
#sidebar.collapsed .sidebar-bottom { opacity: 0; height: 0; padding: 0; border: none; }

/* 折りたたみ時のnav-parentをアイコンのみ中央揃え */
#sidebar.collapsed .nav-parent {
  justify-content: center;
  padding: 8px 0;
}
#sidebar.collapsed .nav-parent > i:first-child { width: auto; margin: 0; }
#sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 8px 0;
  border-left: none;
}
#sidebar.collapsed .nav-item i { width: auto; margin: 0; }
#sidebar.collapsed .nav-item span { display: none; }
