/* style.css */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --bg-color: #f3f4f6;
  --surface: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #1e293b;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 0.5rem;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-size: 0.875rem;
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ===== Login Page ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: #f8fafc;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  z-index: 0;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
}

.orb1 { width: 400px; height: 400px; background: #c7d2fe; top: -100px; left: -100px; }
.orb2 { width: 300px; height: 300px; background: #ddd6fe; bottom: -50px; right: -50px; }
.orb3 { width: 200px; height: 200px; background: #bfdbfe; top: 50%; left: 50%; transform: translate(-50%, -50%); }

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  padding: 2rem;
}

.login-card {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.form-group {
  text-align: left;
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.role-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-top: 0.5rem;
}

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

.role-tabs {
  display: flex;
  background: var(--bg-color);
  padding: 0.25rem;
  border-radius: 2rem;
}

.role-tab {
  border: none;
  background: transparent;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.role-tab.active {
  background: var(--surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  font-weight: 500;
}

.btn-login {
  width: 100%;
  padding: 0.875rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

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

.login-hint {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== Dashboard Layout ===== */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo-icon-svg {
  display: flex;
  align-items: center;
  color: var(--primary);
}

.sidebar-title {
  color: white;
  font-weight: 600;
  font-size: 1.125rem;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.menu-group {
  margin-bottom: 1.5rem;
}

.menu-group-title {
  padding: 0 1.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 0.625rem 1.5rem;
  color: var(--sidebar-text);
  transition: all 0.2s;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.menu-item:hover {
  color: var(--sidebar-active);
  background-color: rgba(255,255,255,0.03);
}

.menu-item.active {
  color: var(--sidebar-active);
  background-color: var(--sidebar-active-bg);
  border-left: 3px solid var(--primary);
  padding-left: calc(1.5rem - 3px);
}

.icon-span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: inherit;
}

.icon-span svg {
  width: 100%;
  height: 100%;
}

/* Main Content */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: 64px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-color);
  padding: 0.375rem 0.75rem;
  border-radius: 2rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.normal { background-color: var(--success); }
.status-dot.delay { background-color: var(--warning); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Content Area */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

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

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-main);
}

.page-actions {
  display: flex;
  gap: 0.75rem;
}

/* Components */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  outline: none;
}

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

.btn-secondary {
  background-color: white;
  border-color: var(--border);
  color: var(--text-main);
}
.btn-secondary:hover { background-color: #f9fafb; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

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

.card-title {
  font-weight: 600;
  font-size: 1.125rem;
}

.card-body {
  padding: 1.5rem;
}

/* Filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.filter-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-select, .filter-input {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.85rem;
  outline: none;
  background: white;
}

.filter-select:focus, .filter-input:focus {
  border-color: var(--primary);
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th, .table td {
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  background-color: #f9fafb;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tr:hover td {
  background-color: #f9fafb;
}

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-primary { background: #e0e7ff; color: #3730a3; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* Grid Layouts */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

/* Stats Card */
.stat-card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

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

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.stat-change {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
}

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

.mini-chart-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: #ffffff;
}

.mini-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.mini-chart-title {
  font-weight: 600;
  color: var(--text-main);
}

.mini-chart-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.chart-frame {
  width: 100%;
  min-height: 160px;
}

.line-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid-line {
  stroke: #e5e7eb;
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--text-muted);
  font-size: 11px;
}

.chart-last-value {
  fill: var(--text-main);
  font-size: 12px;
  font-weight: 700;
}

.status-list {
  display: flex;
  flex-direction: column;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
}

.status-row:last-child {
  border-bottom: none;
}

.status-main {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.status-title {
  font-weight: 600;
}

.status-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.scope-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.permission-matrix {
  display: grid;
  grid-template-columns: 180px repeat(3, minmax(120px, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.permission-cell {
  padding: 0.875rem 1rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: white;
  min-height: 48px;
}

.permission-cell:nth-child(4n) {
  border-right: none;
}

.permission-head {
  background: #f9fafb;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.permission-check {
  color: var(--success);
  font-weight: 700;
}

.permission-empty {
  color: var(--text-muted);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab:hover:not(.active) {
  color: var(--text-main);
}

/* Modal Overlay & Card */
.modal-overlay {
  transition: all 0.3s ease;
  display: flex;
}

@media (max-width: 1200px) {
  .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .grid-4,
  .grid-2,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 1rem;
  }
}
