:root {
  --bg: #f0f2f5;
  --sidebar-bg: #1a1d23;
  --sidebar-text: #c9d1d9;
  --primary: #4f8ff7;
  --primary-hover: #3a7ae0;
  --danger: #e5534b;
  --success: #3fb950;
  --warning: #d29922;
  --card-bg: #fff;
  --text: #24292f;
  --muted: #8b949e;
  --border: #d0d7de;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

#sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 1.5rem 1rem;
  overflow-y: auto;
}

.logo h1 { font-size: 1.3rem; color: #fff; }
.logo .subtitle { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

#agent-list { margin-top: 2rem; }

.agent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
}
.agent-item:hover, .agent-item.active { background: rgba(255,255,255,0.08); }
.agent-item .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-online { background: var(--success); }
.dot-offline { background: var(--muted); }
.agent-item .name { font-size: 0.9rem; }
.agent-item .seen { font-size: 0.7rem; color: var(--muted); }

#main { padding: 2rem; overflow-y: auto; }

.placeholder {
  text-align: center;
  margin-top: 15vh;
  color: var(--muted);
}
.placeholder h2 { color: var(--text); margin-bottom: 0.5rem; }

.hidden { display: none !important; }

#agent-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
}
#agent-header h2 { font-size: 1.4rem; }

.badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-online { background: #dafbe1; color: #1a7f37; }
.badge-offline { background: #f6f8fa; color: var(--muted); }

.muted { color: var(--muted); font-size: 0.85rem; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab {
  padding: 8px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.toolbar label { font-size: 0.85rem; display: flex; align-items: center; gap: 6px; }
.toolbar input[type="date"] { padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; }

.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.9; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--muted);
  background: #f6f8fa;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid #f0f0f0;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .mono { font-family: 'SF Mono', Consolas, monospace; font-size: 0.8rem; }

.badge-blocked { background: #fce8e6; color: var(--danger); }
.badge-ok { background: #dafbe1; color: #1a7f37; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
}
.card h3 { margin-bottom: 1rem; font-size: 1rem; }

.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-size: 0.85rem; margin-bottom: 4px; font-weight: 500; }
.form-row input[type="text"],
.form-row input[type="time"],
.form-row select {
  width: 100%;
  max-width: 350px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}
.day-picker {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.day-picker label {
  display: flex; align-items: center; gap: 4px;
  font-weight: 400; font-size: 0.85rem;
}
.form-actions { display: flex; gap: 8px; margin-top: 1rem; }

.rule-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.rule-info { flex: 1; }
.rule-info .program { font-weight: 600; font-family: 'SF Mono', Consolas, monospace; }
.rule-info .detail { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.rule-actions { display: flex; gap: 6px; }

@media (max-width: 768px) {
  body { grid-template-columns: 1fr; }
  #sidebar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    overflow-x: auto;
  }
  .logo { white-space: nowrap; }
  #agent-list { display: flex; gap: 8px; margin-top: 0; }
  .agent-item { white-space: nowrap; }
  #main { padding: 1rem; }
}
